import math
def PC(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N, M = map(int, input().split())
A = list(map(int, input().split()))
B = []
j = 0
for i in A:
    if j == 0:
        B.append(i)
    else:
        B.append(B[j - 1] + i)
    j += 1
for i in range(len(B)):
    B[i] = B[i] % M
C = sorted(B)
anscnt = 0
samecnt = 1
for i in range(len(C)):
    if C[i] == 0:
        anscnt += 1
    if i != 0:
        if C[i] == C[i - 1]:
            samecnt += 1
        elif samecnt != 1:
            anscnt += PC(samecnt, 2)
            samecnt = 1
        if i == len(C) - 1:
            anscnt += PC(samecnt, 2)
            samecnt = 1
print(anscnt)
            