The programming competition season has already started and it's time to train for ICPC. Sereja coaches his teams for a number of year and he knows that to get ready for the training session it's not enough to prepare only problems and editorial. As the training sessions lasts for several hours, teams become hungry. Thus, Sereja orders a number of pizzas so they can eat right after the end of the competition.
Teams plan to train for _n_ times during _n_ consecutive days. During the training session Sereja orders exactly one pizza for each team that is present this day. He already knows that there will be _a__i_ teams on the _i_\-th day.
There are two types of discounts in Sereja's favourite pizzeria. The first discount works if one buys two pizzas at one day, while the second is a coupon that allows to buy one pizza during two **consecutive** days (two pizzas in total).
As Sereja orders really a lot of pizza at this place, he is the golden client and can use the unlimited number of discounts and coupons of any type at any days.
Sereja wants to order exactly _a__i_ pizzas on the _i_\-th day while using only discounts and coupons. Note, that he will never buy more pizzas than he need for this particular day. Help him determine, whether he can buy the proper amount of pizzas each day if he is allowed to use only coupons and discounts. Note, that it's also prohibited to have any active coupons after the end of the day _n_.
## Input
The first line of input contains a single integer _n_ (1 ≤ _n_ ≤ 200 000) — the number of training sessions.
The second line contains _n_ integers _a_1, _a_2, ..., _a__n_ (0 ≤ _a__i_ ≤ 10 000) — the number of teams that will be present on each of the days.
## Output
If there is a way to order pizzas using only coupons and discounts and do not buy any extra pizzas on any of the days, then print "_YES_" (without quotes) in the only line of output. Otherwise, print "_NO_" (without quotes).
[samples]
## Note
In the first sample, Sereja can use one coupon to buy one pizza on the first and the second days, one coupon to buy pizza on the second and the third days and one discount to buy pizzas on the fourth days. This is the only way to order pizzas for this sample.
In the second sample, Sereja can't use neither the coupon nor the discount without ordering an extra pizza. Note, that it's possible that there will be no teams attending the training sessions on some days.
Let $ a_1, a_2, \dots, a_n $ be non-negative integers representing the number of pizzas needed on day $ i $.
We are allowed to use two types of operations:
- **Discount**: On a single day $ i $, cover two pizzas (i.e., reduce $ a_i $ by 2).
- **Coupon**: Over two consecutive days $ i $ and $ i+1 $, cover one pizza on each (i.e., reduce $ a_i $ by 1 and $ a_{i+1} $ by 1).
We must cover exactly $ a_i $ pizzas on day $ i $, using any number of these operations, and **no active coupon may remain after day $ n $** (i.e., no coupon can extend beyond day $ n $).
Define:
- Let $ x_i \in \mathbb{Z}_{\geq 0} $ be the number of **discounts** used on day $ i $.
- Let $ y_i \in \mathbb{Z}_{\geq 0} $ be the number of **coupons** covering days $ i $ and $ i+1 $, for $ i = 1, 2, \dots, n-1 $.
Then, for each day $ i $, the total number of pizzas covered is:
$$
a_i = 2x_i + y_{i-1} + y_i
$$
with boundary conditions:
- $ y_0 = 0 $ (no coupon before day 1),
- $ y_n = 0 $ (no coupon after day $ n $).
We must determine whether there exist non-negative integers $ x_1, \dots, x_n $ and $ y_1, \dots, y_{n-1} $ satisfying the above system.
---
**Formal Problem Statement:**
Given $ a_1, a_2, \dots, a_n \in \mathbb{Z}_{\geq 0} $, determine whether there exist non-negative integers $ x_1, \dots, x_n $ and $ y_1, \dots, y_{n-1} $ such that for all $ i = 1, \dots, n $:
$$
a_i = 2x_i + y_{i-1} + y_i
$$
where $ y_0 = y_n = 0 $.
---
**Equivalently, we can solve greedily:**
We process days left to right. For day $ i $, the number of pizzas already covered by coupons from day $ i-1 $ is $ y_{i-1} $. The remaining pizzas to cover on day $ i $ is $ r_i = a_i - y_{i-1} $. This must be non-negative.
Then, we can use:
- As many discounts as possible (i.e., subtract even parts),
- The remainder (if any) must be covered by starting new coupons to day $ i+1 $, i.e., set $ y_i = r_i \mod 2 $, and use $ x_i = \lfloor r_i / 2 \rfloor $.
But since coupons must end at day $ n $, we require $ y_n = 0 $, so after processing day $ n $, we must have $ r_n = a_n - y_{n-1} $ even and non-negative.
Thus, the algorithm is:
1. Initialize $ y = 0 $ (coupon carried over from previous day).
2. For $ i = 1 $ to $ n $:
- $ r = a_i - y $
- If $ r < 0 $: return NO.
- If $ r $ is odd and $ i < n $: set $ y = 1 $ (use one coupon to next day), and $ x_i = (r - 1)/2 $.
- If $ r $ is odd and $ i = n $: return NO (cannot leave active coupon).
- If $ r $ is even: set $ y = 0 $, $ x_i = r/2 $.
3. If we complete the loop, return YES.
But note: we may choose to use *more* coupons than strictly necessary? Actually, no — we must cover *exactly* $ a_i $, and we cannot overbuy. So the above greedy is forced: at each day, the leftover after subtracting incoming coupons must be covered by discounts and outgoing coupons, and since discounts cover 2, the parity of the leftover forces the number of outgoing coupons.
Thus, the **necessary and sufficient condition** is:
> There exists a sequence $ y_1, \dots, y_{n-1} \in \{0,1\} $ such that for all $ i \in \{1, \dots, n\} $,
> $ a_i - y_{i-1} - y_i \geq 0 $ and is even,
> with $ y_0 = y_n = 0 $.
And we can compute this greedily:
Let $ y = 0 $.
For $ i = 1 $ to $ n $:
$ r = a_i - y $
If $ r < 0 $: return NO
If $ i == n $:
if $ r $ is odd: return NO
else: continue
Else:
if $ r $ is odd: $ y = 1 $
else: $ y = 0 $
If we finish: return YES.
---
**Final Formal Statement:**
Let $ a = (a_1, \dots, a_n) \in \mathbb{Z}_{\geq 0}^n $. Define a sequence $ y_0, y_1, \dots, y_n \in \{0,1\} $ with $ y_0 = y_n = 0 $, and for each $ i \in \{1, \dots, n\} $, define:
$$
r_i = a_i - y_{i-1}
$$
Then, $ y_i = r_i \mod 2 $ for $ i < n $, and $ y_n = 0 $.
We require $ r_i \geq 0 $ for all $ i $, and $ r_n $ even.
The system is feasible **if and only if** the greedy assignment yields $ r_i \geq 0 $ for all $ i $ and $ r_n $ even.
Thus, the problem reduces to checking feasibility of this greedy propagation.
---
**Mathematical Condition:**
There exists a sequence $ y_1, \dots, y_{n-1} \in \{0,1\} $ such that:
- $ a_1 - y_1 \geq 0 $ and even,
- $ a_i - y_{i-1} - y_i \geq 0 $ and even for $ i = 2, \dots, n-1 $,
- $ a_n - y_{n-1} \geq 0 $ and even.
with $ y_0 = y_n = 0 $.
This is equivalent to the greedy algorithm above.