You are on page 1of 1

Subset Fight

Input file: standard input


Output file: standard output
Time limit: 1 second
Memory limit: 32 megabytes

A war is coming, you have to help the combatants find their odds of victory
We are given an array of n integers, where vi is the number of numbers equal with i. A scenario where
the humanity is victorious is a scenario where the sum of the numbers from the subset is multiple of n.
For example, if n = 3 and the numbers from the array are 1, 2 and 3, the array is 1 2 2 3 3 3.
Even though a number shows up multiple times in the resulting array, the subsets formed by those numbers
are different.
With other words, we can count the elements from the array with 1, 2, ..., v1 + v2 + ... + vn , and we have
to find how many subsets among the 2v1 +v2 +...+vn have the sum a multiple of n.
Since the number of subsets can be quite large, we need to print its number modulo 109 + 7.

Input
On the first line we have one integer, n (1 ≤ n ≤ 100).
On the next line we have the n integers (1 ≤ vi ≤ 2 ∗ 105 ).
For tests worth 20 points, ( n1 vi ≤ 20).
P

For other tests worth 40 points, ( n1 vi ≤ 105 )


P

Output
On the first line the required answer should be printed.

Examples
standard input standard output
3 4
1 1 1
5 985611225
69 420 1017 128 953

Note
For the first sample, the correct subsets are the empty set, 1, 2, 3, 1, 2, 3.

Page 1 of 1

You might also like