The Digital SymphonyHard

The Digital Symphony

Hard+80 XP · +25 Auramathnumber theorycombinatorics

Aarav is composing a digital symphony. He has a list of n unique musical notes, each represented by a positive integer from 1 to 200000. Aarav believes that two notes, say a and b, create a harmonious pair if their sum (a + b) is divisible by a secret integer k. He wants to find the number of pairs of distinct notes (a, b) from his list such that a < b and a + b is divisible by k.

Your task is to help Aarav find this count. Given the list of n unique musical notes and the integer k, count the number of pairs (a, b) from the list satisfying a < b and (a + b) % k == 0.

Input

The first line contains two integers n and k (2 <= n <= 200000, 2 <= k <= 200000). The second line contains n distinct positive integers, a_1, a_2, ..., a_n, representing the musical notes. Each note a_i is between 1 and 200000.

Output

Print a single integer, the total count of harmonious pairs.

Constraints

2 <= n <= 200000 2 <= k <= 200000 1 <= a_i <= 200000 All a_i are distinct.

Time limit 1 s (native code; slower languages get more)Memory 256 MB15 hidden tests

Example 1

Input
5 3
1 2 3 4 5
Output
4

Pairs are (1, 2), (1, 5), (2, 4), (4, 5). Sums are 3, 6, 6, 9, all divisible by 3.

Example 2

Input
4 4
1 2 3 4
Output
1

Pairs are (1, 3), (4, 4) - wait, distinct notes. So (1,3), (4,4) is not valid. Should be (1,3), (2,?) (3,?). Only (1,3) works (sum 4). Wait (a,b) such that a < b. (1,3) sum 4. (1,?) (2,?) (3,?). Pairs: (1,3) sum 4. (1, ?) (2, ?) (3, ?). Distinct notes. Ah, the input notes are unique. The pair must b

Hints