The Right Tip
During the recent Football Worldcup, a
group of friends worked at a courtyard café to pay for their holidays. Everyday
they would collect all the tips given by the customers on a jar, and at the end
of the day they wanted to split the tips equally between them. After a few
days, they reached the conclusion that (given the various face values of euro
coins) sometimes it was not possible to equally split the collect of the day
between them.
Write a program to help the friends
determine if it is possible (or not) to equally split the collect of the day
between them.
Input
The input will consist of a sequence of
pairs of lines, each pair represents a coin division problem to be solved. For
each such pair the first line contains the number of friends (a positive
integer not greater than 5). The second line contains eight space separated
non-negative integers n1, n2,..., n8, where ni
is the number of coins of value i (0.01, 0.02, 0.05, 0.10, 0.20, 0.50, 1.00 and
2.00 euros respectively, e.g., the number of 5 cents coins will be denoted by n3).
The maximum number of coins is 10000. Input is terminated by a single line with
the number -1.
Output
For each coin division problem print
either "yes" or "no", depending on whether it is possible or not to divide equally the
tips by the friends.
Sample Input
2
1 1 1 1 1
1 1 1
2
2 1 2 1 5
2 2 1
1
3423 234
324 972 740 12 234 901
4
147 5502
3486 434 76 66 267 20
5
3015 3590
1559 1219 78 507 23 8
-1
Sample Output
no
yes
yes
no
yes