Petr and a Combination Lock
Hazrat Ali
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:

Petr called his car dealer, who instructed him to rotate the lock's wheel exactly n times. The i-th rotation should be ai 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.
The first line contains one integer n (1≤n≤15) — the number of rotations.
Each of the following n lines contains one integer ai (1≤ai≤180) — the angle of the i-th rotation in degrees.
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).
3 10 20 30
YES
3 10 10 10
NO
3 120 120 120
YES
Solution