Hello 2019
B
Petr and a Combination Lock
Codeforces
1200
原题
← AC →
翻译中…

Petr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of $360$ degrees and a pointer which initially points at zero:

翻译中…

image

翻译中…

Petr called his car dealer, who instructed him to rotate the lock's wheel exactly $n$ times. The $i$-th rotation should be $a_i$ degrees, either clockwise or counterclockwise, and after all $n$ rotations the pointer should again point at zero.

翻译中…

This confused Petr a little bit as he isn't sure which rotations should be done clockwise and which should be done counterclockwise. As there are many possible ways of rotating the lock, help him and find out whether there exists at least one, such that after all $n$ rotations the pointer will point at zero again.

翻译中…

Input

翻译中…

The first line contains one integer $n$ ($1 \leq n \leq 15$) — the number of rotations.

翻译中…

Each of the following $n$ lines contains one integer $a_i$ ($1 \leq a_i \leq 180$) — the angle of the $i$-th rotation in degrees.

翻译中…

Output

翻译中…

If it is possible to do all the rotations so that the pointer will point at zero after all of them are performed, print a single word "YES". Otherwise, print "NO". Petr will probably buy a new car in this case.

翻译中…

You can print each letter in any case (upper or lower).

翻译中…

Note

翻译中…

In the first example, we can achieve our goal by applying the first and the second rotation clockwise, and performing the third rotation counterclockwise.

翻译中…

In the second example, it's impossible to perform the rotations in order to make the pointer point at zero in the end.

翻译中…

In the third example, Petr can do all three rotations clockwise. In this case, the whole wheel will be rotated by $360$ degrees clockwise and the pointer will point at zero again.

翻译中…

样例

Input #1
3
10
20
30
Output #1
YES
InputCopy OutputCopy
Input #2
3
10
10
10
Output #2
NO
InputCopy OutputCopy
Input #3
3
120
120
120
Output #3
YES
InputCopy OutputCopy
题目信息
题号
1097B
所属比赛
时间限制
1 s
内存限制
256 MB
标签
位运算
暴力
动态规划

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。