def shakutori(a,M):
  left =0
  right = 0
  su = 0
  ans = 0
  for i in range(len(a)):
    su +=a[right]
    right +=1
    if su%M==0:
      ans+=1
      while su%M!=0:
        su -=a[left]
        left+=1
  return ans
from itertools import accumulate
N,M = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
A = list(accumulate(A))
A = list(map(lambda x: x%M,A))
ans = {}
ans1=0
for i in range(N):
  if A[i] in ans:
    ans[A[i]] +=1
  else:
    ans[A[i]] =1
  ans1 += ans[A[i]]-1
ans1 += ans[0]
print(ans1)