Remainder Subarray Count

No attempts yetTime limit1sMemory limit256 MB

Problem

You are given a sequence A1,A2,,ANA_1, A_2, \dots, A_N of length NN. Count the contiguous intervals whose sum is divisible by MM.

An interval is a pair (i,j)(i, j) with 1ijN1 \le i \le j \le N, and it covers AiA_i through AjA_j. Two intervals count as different when they differ in ii or in jj.

Input

The first line contains NN and MM, separated by a space. (1N1061 \le N \le 10^6, 2M1032 \le M \le 10^3)

The second line contains the NN numbers of the sequence A1,A2,,ANA_1, A_2, \dots, A_N, separated by spaces. (0Ai1090 \le A_i \le 10^9)

Output

Print the number of intervals that satisfy the condition on the first line.