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

d = {0: 1}
s = 0
ans = 0

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

print(ans)