from collections import defaultdict
N, M = map(int, input().split())
A = list(map(int, input().split()))
acc = 0
s = defaultdict(int)
s[0] = 1
ans = 0
for a in A:
    acc = (acc + a) % M
    ans += s[acc]
    s[acc] += 1
print(ans)
