cswork / OAOpen practice workspace

Two SigmaOA #2

Nums That Are Divisible by N

Estimated MediumJudge-ready

Topics (AI-labelled)HashingBits & Math

Count the index pairs with i<j such that a[i]+a[j] is divisible by N. Elements with duplicate values still have distinct identities, and an element cannot be paired with itself.

Input

The first line contains the array length n and the divisor N, and the second line contains n numbers. Complete original bounds: 1≤n≤100000, 1≤N≤10^9, 1≤a[i]≤10^9; output a 64-bit integer.

Output

Output one integer answer.

Example 1

Input:

5 3
5 4 3 2 1

Output:

4

Example 2

Input:

3 2
1 1 1

Output:

3

Example 3

Input:

1 3
3

Output:

0

Example notes

The first example has 4 pairs: original indices (0,1), (0,4), (1,3), and (3,4). The original explanation reversed the array without updating the indices accordingly; this site corrects it. The other two examples give 3 and 0.

Editorial

Loading solution…