from collections import Counter
N, M = map(int, input().split())
A = list(map(int, input().split()))
for i in range(N-1):
    A[i] %= M
    A[i+1] += A[i]
    A[i+1] %= M

c = Counter(A)
ans = 0
for k, v in c.items():
    if k == 0:
        ans += v
    ans += v * (v-1) // 2

print(ans)