시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 (추가 시간 없음) 1024 MB34242369.697%

문제

Grammy likes to eat noodles. She divided a very long strip of noodle into $N$ parts of unit length. Each part $i$ has deliciousness $a_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 $n$ be the current length of the noodle. In each operation, Grammy can choose a length $\ell$ such that $2 \ell \leq n$ and $a_i > 0$ for all $i \leq \ell$, and fold the noodle $a_1, a_2, \ldots, a_\ell, a_{\ell + 1}, \ldots, a_{2 \ell}, a_{2 \ell + 1}, \ldots, a_n$ into $a_{\ell + 1} + a_\ell, a_{\ell + 2} + a_{\ell - 1}, \ldots, a_{2 \ell} + a_1, a_{2 \ell + 1}, \ldots, a_n$, where $n$ is the length of the noodle before the operation. After the operation, the length will become $n - \ell$.

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

입력

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

The second line contains $N$ integers $a_i$ ($-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 $1$, output a single line with the word "YES". Otherwise, output a single line with the word "NO".

예제 입력 1

3
1 2 -5

예제 출력 1

YES

예제 입력 2

5
2 -5 2 3 1

예제 출력 2

NO