Hell on the Markets
Time limit2sMemory limit128 MB
Decide if signs (+1/-1) can be assigned to a given sequence with 1<=a_i<=i so the signed sum is zero.
Problem
During a financial crisis many institutions became insolvent and were either liquidated or absorbed by larger ones, so that by the end only two banks were still operating. The financial markets, closed throughout the crisis, are now being reopened gradually by the regulators. To curb speculation and ramp up trading slowly, at first only a single financial instrument may be traded, and during the -th minute of operation the traded volume is limited to contracts.
The two banks agree in advance on the trading volume for every minute of this first session. During the -th minute () exactly contracts change hands (): one bank buys them and the other one sells them. An outside observer sees only the volume . Neither bank wants to carry any position once the session ends. Let if the first bank is the buyer during the -th minute and if it is the seller (i.e. the second bank buys). Then both banks finish with no position exactly when
Given the agreed volumes , determine whether a buyer and a seller can be assigned to every minute so that both banks end the session with no position.
Input
The first line contains a single integer ().
The second line contains integers ().
Output
Print Yes if buyers and sellers can be assigned to every minute so that , and No otherwise.