#CCBCHBAHAI0000058. Divisible Sum Pairs (Divisible Sum Pairs)

    ID: 976 Loại: Thông thường 2000ms 256MiB Tried: 0 Đã chấp nhận: 0 Độ khó: 1 Đăng bởi: Nhãn>Programming language basicsStatic arraysIteration techniquesImplementation techniquesWorking with numbersInteger arithmetic

Divisible Sum Pairs (Divisible Sum Pairs)

Divisible Sum Pairs (Divisible Sum Pairs)

Source: HackerRank

Version: Phuoc Hung OJ Extended

Problem

Given a0,a1,…,an−1a_0,a_1,\ldots,a_{n-1} and a positive integer kk, count index pairs (i,j)(i,j) such that

0≤i<j<n0\le i<j<n

and

(ai+aj) mod k=0.(a_i+a_j)\bmod k=0.

Each index pair is counted once.

Input

The first line contains nn and kk. The second line contains nn integers aia_i.

Output

Print the number of valid pairs.

Subtask

Subtask 1 (20 points): 2≤n≤202\le n\le20, 1≤k,ai≤201\le k,a_i\le20.

Subtask 2 (30 points): 2≤n≤602\le n\le60, 1≤k,ai≤1001\le k,a_i\le100.

Subtask 3 (50 points): 2≤n≤1002\le n\le100, 1≤k≤1001\le k\le100, 1≤ai≤1001\le a_i\le100.

Example

Input

6 3
1 3 2 6 1 2

Output

5

Explanation

The sample follows the definitions and rules above.