아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Ramen

시간 제한1초메모리 제한1024 MB

요약
왼쪽 절반이 모두 양수인 구간을 접는 연산을 반복해 길이 1로 줄일 수 있는지 판정한다.
난이도

보통10점 중 6점

유형
그리디, 구현
정답자
아직 제출이 없습니다

문제

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 2ℓ≤n2 \ell \leq n and a_i>0a\_i > 0 for all i≤ℓi \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 n−ℓn - \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 (1≤N≤100,0001 \leq N \leq 100\\,000).

The second line contains NN integers a_ia\_i (−20,000≤a_i≤20,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".

예제2

  1. 예제 1

    입력
    3
    1 2 -5
    
    예상 출력
    YES
    
  2. 예제 2

    입력
    5
    2 -5 2 3 1
    
    예상 출력
    NO