from collections import Counter
n, m = map(int, input().split())
a = list(map(int, input().split()))
cum = [0] * (n + 1)
for i in range(n):
    cum[i + 1] = (cum[i] + a[i]) % m
c = Counter(cum)
ans = 0
for v in c.values():
    ans += v * (v - 1) // 2
print(ans)