#Lutece3326. Muzikant

Muzikant

Description

Muzikant aspires to be a musician and has learned how to write a music score.

A score is made up of several bars, each containing notes of various lengths. The duration of a binary note is half of a bar, while a crotchet is one-quarter and a quaver is one-eighth. Muzikant soon discovered that the duration of most notes is equal to the duration of 12k\frac 1{2^k} of a bar.[1]

Muzikant then tried to write a score himself. He was so engrossed in his composition that he lost track of how long he had been writing. He wonders whether the notes he has written down could exactly form a bar. So he hands you his score and asks for your assistance.

More precisely, the score given to you by Muzikant consists of nn notes, and the duration of the ii-th note is 12ai\frac 1{2^{a_i}} of a bar. Your task is to check whether these notes can form an exact bar, in other words, whether the sum of all notes' duration is equal to the duration of a bar.

Input

The first line contains an integer n (1n106)n\ (1\le n\le 10^6), the number of notes in Muzikant's score.

The second line contains nn integers a1,a2,,an (1ai106)a_1, a_2, \ldots, a_n\ (1\le a_i\le 10^6), denoting the duration of the ii-th note in Muzikant's score is 2ai2^{a_i}-th of a whole bar.

Output

If the notes in Muzikant's score can exactly form a single bar, print a single line Yes. Otherwise, print No.

Samples

2
1 1
Yes
3
1 2 2
Yes
10
4 4 3 3 3 4 4 3 3 3
Yes
9
3 3 3 3 4 4 4 4 3
No

Note

For the sake of simplicity, we assume that the duration of a bar is 1 second.

In the first example, Muzikant wrote two notes with the duration of 12\frac12 seconds. Obviously, two halves make a whole bar.

In the second example, Muzikant wrote three notes of 12\frac 12s, 122\frac 1{2^2}s, 122\frac 1{2^2}s, respectively. Since 12+122+122=1\frac 12 + \frac 1{2^2} + \frac 1{2^2} = 1, these three notes form a bar.

In the third example, the total length of notes is 4×124+6×123=14\times\frac 1{2^4} + 6\times\frac 1{2^3} = 1, so the answer is Yes.

In the fourth example, the total length of notes is 781\frac 78\ne 1, so the answer is No.

Resources

电子科技大学第十四届 ACM 趣味程序设计竞赛


  1. Indeed, there are many notes whose duration doesn't match that form, such as triplets, but here we will not take them into consideration. Besides, for the sake of simplicity, here we only consider bars of 44\frac 44 beat. ↩︎