Ramen

아직 제출이 없습니다시간 제한1초메모리 제한1024 MB

문제

Grammy likes to eat noodles. She divided a very long strip of noodle into NN parts of unit length. Each part ii has deliciousness a_ia\_i. She would like to fold the noodle into one piece of unit length before eating by repeating the following operation several (possibly, zero) times.

Let nn be the current length of the noodle. In each operation, Grammy can choose a length \ell such that 2n2 \ell \leq n and a_i>0a\_i > 0 for all ii \leq \ell, and fold the noodle a_1,a_2,,a_,a_+1,,a_2,a_2+1,,a_na\_1, a\_2, \ldots, a\_\ell, a\_{\ell + 1}, \ldots, a\_{2 \ell}, a\_{2 \ell + 1}, \ldots, a\_n into a_+1+a_,a_+2+a_1,,a_2+a_1,a_2+1,,a_na\_{\ell + 1} + a\_\ell, a\_{\ell + 2} + a\_{\ell - 1}, \ldots, a\_{2 \ell} + a\_1, a\_{2 \ell + 1}, \ldots, a\_n, where nn is the length of the noodle before the operation. After the operation, the length will become nn - \ell.

Grammy wants to know whether she can fold the noodle to length 11, can you tell her?

입력

The first line of input contains a single integer NN (1N100,0001 \leq N \leq 100\\,000).

The second line contains NN integers a_ia\_i (20,000a_i20,000-20\\,000 \leq a\_i \leq 20\\,000), representing the deliciousness of each part of the noodle.

출력

If Grammy can fold the noodle to length 11, output a single line with the word "YES". Otherwise, output a single line with the word "NO".