Subset Fight

Time limit: 0.2s Memory limit: 256MB Input: Output:

We are given an array on nn integers, where viv_i is the number of numbers equal with ii. A scenario where the humanity is victorious is a scenario where the sum of the numbers from the subset is multiple of nn.

For example, if n=3n = 3 and the numbers from the array are 11, 22 and 33, the array is {1,2,2,3,3,3}\{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 11, 22, ..., v1+v2+...+vnv_1 + v_2 + ... + v_n, and we have to find how many subsets among the 2v1+v2+...+vn2^{v_1 + v_2 + ... + v_n} have the sum a multiple of nn.

Since the number of subsets can be quite large, we need to print its number modulo 109+710^9 + 7.

Input

On the first line we have one integer, nn (1n1001 \leq n \leq 100). On the next line we have the nn integers (1vi21051 \leq v_i \leq 2 * 10^5).

For tests worth 20 points, i=1nvi20\sum_{i=1}^{n} v_i \leq 20.
For other tests worth 40 points, i=1nvi105\sum_{i=1}^{n} v_i \leq 10^5.

Output

On the first line the required answer should be printed.

Example 1

stdin

3
1 1 1

stdout

4

Explanation

The correct subsets are {}\{ \}, {1,2}\{1, 2\}, {3}\{3\} and {1,2,3}\{1, 2, 3\}.

Example 2

stdin

5
69 420 1017 128 953

stdout

985611225

Log in or sign up to be able to send submissions!