from collections import Counter
N, M = map(int, input().split())
As = list(map(int, input().split()))

ct = Counter()
ct[0] = 1
s = 0
ans = 0
for a in As:
    s += a
    mod = s % M
    ans += ct[mod]
    ct[mod] += 1
print(ans)