Divisible Array
Обмеження: 2 сек., 512 МіБ
You are given a sequence aa of nn non-negative integers.
Determine if there exists a sequence bb that is a permutation of aa such that bibi is a multiple of (bi+1+bi+2)(bi+1+bi+2) for all 1≤i≤n−21≤i≤n−2.
Вхідні дані
The first line contains an integer nn – the number of elements in sequence aa.
The second line contains nn integers aiai – the elements of sequence aa.
Вихідні дані
If there exists a sequence bb
satisfying the condition, print Yes
. Otherwise, print
No
.
Обмеження
3≤n≤1063≤n≤106,
1≤ai≤1091≤ai≤109.
Приклади
Вхідні дані (stdin) | Вихідні дані (stdout) |
---|---|
4 40 4444 4 4 | Yes |
Вхідні дані (stdin) | Вихідні дані (stdout) |
---|---|
7 4 7 77 4 477 4747 777444777 | No |
Примітки
In the first example, the sequence b=(4444,40,4,4)b=(4444,40,4,4) satisfies the condition.
b1=4444b1=4444 is a multiple of b2+b3=40+4=44b2+b3=40+4=44.
b2=40b2=40 is a multiple of b3+b4=4+4=8b3+b4=4+4=8.
In the second example, there does not exist a sequence satisfying the condition.