n,m = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
b = {}
b[0] = 1
sum=0
for i in range(0,n):
  sum += a[i]
  sum = sum%m
  if sum in b:
    ans += b[sum]
    b[sum] = b[sum]+1
  else:
    b[sum] = 1
print(ans)