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

s = [0]#s[i]はaからi個取った累積和
for i in range(len(a)):
    s.append((s[i] + a[i]) % m)

ans = 0
d = dict()
for i in range(len(s)):
    t = d.get(s[i], 0)
    ans += t
    d[s[i]] = t + 1
print(ans)