n,m = map(int,input().split())
a = list(map(int,input().split()))
s = [0]*(n+1)
for i in range(1,n+1):
  s[i] = (s[i-1]+a[i-1])%m
s.sort()
t = 0
i = 0
while i<n+1:
  j = i
  while j<n+1 and s[j] == s[i]:
    j += 1
  t += (j-i)*(j-i-1)//2
  i = j
print(t)