N, M = (list)(map(int, input().split()))
A = (list)(map(int, input().split()))
A[0] %= M

for i in range(1, N):
    A[i] += A[i-1]
    A[i] %= M

ans = 0
for i in range(M):
    if i == 0:
        ans += A.count(i)
    c = A.count(i)
    if c >= 2:
        ans += c*(c-1)//2
print(ans)
