Given a sequence of integers
and a positive integer
, count the number of pairs
that satisfy the following two conditions:
, and
.
Input Specification
The first line contains integer and
, separated by a space.
The second line contains integers, which denotes
.
In 50% of the test cases, .
Output Specification
The output contains an integer, which denotes the number of pairs that satisfies the two conditions.
If the output is smaller than , please keep it as is. Otherwise, output the number mod
.
Sample Input 1
5 6
1 2 3 4 5
Sample Output 1
6
Explanation for Sample Output 1
Among the pairs, ,
,
,
,
,
satisfy the conditions.
Sample Input 2
5 12
3 6 8 2 8
Sample Output 2
7
Explanation for Sample Output 2
,
,
,
,
,
,
satisfy the conditions.
Comments