n,m = map(int, input().split())
a = list(map(int, input().split()))
# 累積和
s = []
s.append(0)
for idx in range(len(a)):
  s.append((s[idx] + a[idx]) % m)

c = {0:1}
ans = 0
for l in range(1, n+1):
  ans += c.get(s[l],0)
  c[s[l]] = c.get(s[l],0) + 1
print(ans)
