from collections import defaultdict

N, M = map(int, input().split())
a = tuple(map(int, input().split()))

ans = 0
d = defaultdict(int)
d[0] = 1

t = 0
for aa in a:
    t += aa
    ans += d[t % M]
    d[t % M] += 1
print(ans)
