scount

Time limit: 0.3s Memory limit: 64MB Input: Output:

Task

Kida decided to test you knowledge again. You are given a list VV, of NN integers. Kida asks you to count the number of interesting subsets that satisfy the following condition: for any two numbers VxV_x and VyV_y in the subset, VxV_x appears in the subset the same number of times as VyV_y.

Two subsets are considered different if there is at least one value ii such that ViV_i is in one subset but not in the other. Note that two different subsets might contain the exactly same numbers.

Since this number can be very large, you need to count it modulo 109+710^9+7.

Input

The first line contains the only integer NN (1N100 0001 \le N \le 100\ 000). The second line contains NN integers ViV_i (1Vi1 000 000 0001 \le V_i \le 1\ 000\ 000\ 000 for each i=0N1i=0\ldots N-1).

For tests worth 2020 points: 1N121 \le N \le 12;
For tests worth 2020 points: 1Vi21 \le V_i \le 2;
For tests worth 3030 points: 1N10001 \le N \le 1000;
For tests worth 3030 points: No additional limitations.

Output

You need to write a single line with an integer: the number of interesting subsets modulo 109+710^9 + 7.

stdin

3
1 2 2

stdout

7

stdin

5
1 2 2 1 3

stdout

21

Notes

In the first sample case, the 77 interesting subsets are {}\{\}, {V0}\{V_0\}, {V1}\{V_1\}, {V2}\{V_2\}, {V0,V1}\{V_0, V_1\}, {V0,V2}\{V_0, V_2\}, {V1,V2}\{V_1, V_2\}.

{V0,V1,V2}\{V_0, V_1, V_2\} is not interesting since the number 22 appears twice and the number 11 appears only once.

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