407642: GYM102862 F Cell Borders
Description
You are given a strip of paper that consists of $$$n$$$ consecutive square cells. The cells are numbered $$$1$$$ to $$$n$$$ from left to right. Each cell has an integer written in it, which is either $$$0$$$, $$$1$$$, or $$$2$$$. Denote the integer in the $$$i$$$-th cell by $$$a_i$$$. You can color black any number of the left or right borders of these cells (there are $$$n+1$$$ such borders in total). Is it possible to color the borders in such a way that for each cell $$$i$$$, the number of its borders that is colored is equal to $$$a_i$$$?
For example, if you are given the numbers $$$1~2~1~0~1~2$$$, then it is possible to color the borders as follows:
The first line of input contains a single integer $$$n$$$, the number of cells ($$$1 \leq n \leq 10^5$$$). The next line contains $$$n$$$ integers $$$a_1$$$, $$$\ldots$$$, $$$a_n$$$ ($$$0 \leq a_i \leq 2$$$), the numbers of colored borders the cells $$$1$$$, $$$\ldots$$$, $$$n$$$ should have.
OutputIf it is possible, output "Yes" in a single line, otherwise output "No".
ExamplesInput6 1 2 1 0 1 2Output
YesInput
2 2 0Output
No