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

cum =[0 for _ in range(n)]
cum[0] = a[0] % m
for i in range(1, n):
    cum[i] = cum[i-1] + a[i] % m
    cum[i] %= m

ans = 0
cnt = [0 for _ in range(m)]

for i in cum:
    ans += cnt[i]
    cnt[i] += 1
ans += cnt[0]
print(ans)
