n, m = map(int, input().split())
a = list(map(int, input().split()))

l = [0 for j in range(0, m)]
l[0] = 1
s = 0
ans = 0

for i in range(0, n):
    s += a[i]
    ans += l[s%m]
    l[s%m] += 1

print(ans)