There are chocolates in a row, numbered from to from left to right. The bitterness of chocolate is , and is even.
In one move, you eat two chocolates that are currently adjacent. The bitterness of this bite is the maximum of their bitterness values. The remaining chocolates close the gap without changing their relative order.
You continue until all chocolates have been eaten. Determine whether the sum of the bitterness of all bites is the same for every possible sequence of moves.
For each test case, determine whether every possible sequence of moves has the same total bitterness.
For each test case, print Yes if every possible sequence of moves has the same total bitterness; otherwise, print No.
The answer is case-insensitive.
Eating the first two chocolates and then the last two gives . Eating the middle two first and then the remaining two also gives .
Eating the first two chocolates and then the last two gives . Eating the middle two first and then the remaining two gives , so the totals can differ.
Every sequence has total bitterness . For example, eating the initial adjacent pairs gives .
Eating the initial adjacent pairs gives . Eating the two middle chocolates first and then the remaining pair gives .