N, M = map(int, input().split())
c = [0] * M
A = map(int, input().split())

S = [0]
w = 0
for a in A:
    w += a
    S.append(w % M)

S.sort()
ans = 0
prev = S[0]
c = 1
for i in range(1, N+1):
    if S[i] != prev:
        prev = S[i]
        ans += c * (c - 1) // 2
        c = 1
    else:
        c += 1
ans += c * (c - 1) // 2
print(ans)
