from collections import defaultdict
N, M = map(int, input().split())
A = [int(i) for i in input().split()]

d = defaultdict(int)

s = 0
for i in range(N):
    d[s % M] += 1
    s += A[i]
d[s % M] += 1


ans = 0
for v in d.values():
    ans += v*(v-1)//2
print(ans)
