#arc125d. [arc125_d]Unique Subsequence
[arc125_d]Unique Subsequence
Problem Statement
Given is a sequence of integers .
Find the number of non-empty subsequences of satisfying the following condition, modulo .
- There is only one way to extract from . Formally, there uniquely exists a sequence of indices such that (), where .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
3
1 2 1
Sample Output 1
5
The following five subsequences satisfy the condition.
The subsequence does not satisfy the condition since there are two ways to extract it.
Sample Input 2
4
4 2 1 3
Sample Output 2
15
Sample Input 3
12
1 2 3 6 9 2 3 3 9 6 1 6
Sample Output 3
1178