#arc160c. [arc160_c]Power Up
[arc160_c]Power Up
Problem Statement
You are given a multiset of positive integers with elements: .
You may repeat the following operation any number of times (possibly zero).
- Choose a positive integer that occurs at least twice in . Delete two occurrences of from , and add one occurrence of to .
Find the number, modulo , of multisets that can be in the end.
Constraints
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
4
1 1 2 4
Sample Output 1
3
can be one of the three multisets $\\lbrace 1,1,2,4 \\rbrace,\\lbrace 2,2,4 \\rbrace,\\lbrace 3,4 \\rbrace$ in the end.
You can make as follows.
- Choose . Delete two s from and add one to , making .
- Choose . Delete two s from and add one to , making .
Sample Input 2
5
1 2 3 4 5
Sample Output 2
1
Sample Input 3
13
3 1 4 1 5 9 2 6 5 3 5 8 9
Sample Output 3
66