n,m = map(int, input().split())
ans = 0
a = list(map(int, input().split()))
b = [0]*(n+1)
for i in range(1,n+1):
  b[i] = (a[i-1] + b[i-1])%m
f = [0]*m
for i in b:
  f[i] += 1
for i in f:
  ans += i*(i-1)//2
print(ans)