Hide

Problem D
Late Halloween

/problems/latehalloween/file/statement/en/img-0001.jpg
Source: Pixabay

It’s currently Halloween and there are three children trick-or-treating at your house. The problem is that it’s getting late, and you want to hand out the rest of your goodie bags. You have several bags, but you didn’t have time to count out candies, so each bag has a varying number of candies. Return whether it is possible to partition the bags so that each child has the same number of candies and no bags are leftover.

Input

The input begins with an integer $n$ ($1 < n < 1000$) which denotes the number of goodie bags. The next line contains $n$ space separated integers $c_ i$ ($1 < c_ i < 100$) that describe the number of candies in each goodie bag. The sum of all $c_ i$ is guaranteed to be less than $3\, 000$.

Output

Output True if you can fairly distribute the goodie bags, otherwise, output False.

Sample Input 1 Sample Output 1
10
9 7 3 5 1 4 2 1 4 3
True
Sample Input 2 Sample Output 2
5
2 2 2 1 2
False

Please log in to submit a solution to this problem

Log in