Ramen
시간 제한1초메모리 제한1024 MB
왼쪽 절반이 모두 양수인 구간을 접는 연산을 반복해 길이 1로 줄일 수 있는지 판정한다.
문제
Grammy likes to eat noodles. She divided a very long strip of noodle into parts of unit length. Each part has deliciousness . 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 be the current length of the noodle. In each operation, Grammy can choose a length such that and for all , and fold the noodle into , where is the length of the noodle before the operation. After the operation, the length will become .
Grammy wants to know whether she can fold the noodle to length , can you tell her?
입력
The first line of input contains a single integer ().
The second line contains integers (), representing the deliciousness of each part of the noodle.
출력
If Grammy can fold the noodle to length , output a single line with the word "YES". Otherwise, output a single line with the word "NO".