Shift and Reverse
时间限制:C/C++/Rust/Pascal 3秒,其他语言6秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

Bobo has a sequence . He can rearrange the sequence using the following operation any number of times:

+ Select an integer i () and change the sequence to .

Bobo would like to know the number of different sequences can be obtained modulo .

输入描述:

The input consists of several test cases terminated by end-of-file. For each test case:

The first line contains an integer n, the length of the sequence.

The second line contains n integers .

*
*
* The sum of n does not exceed .

输出描述:

For each test case, print an integer which denotes the result.

                    
示例1

输入

复制
4
1 1 1 1
4
1 1 2 2
4
1 2 1 2
4
2 1 2 1

输出

复制
1
4
2
2