n,m=map(int,input().split())
a=list(map(int,input().split()))
b=[a[0]%m]
for i in a[1:]:b.append((b[-1]+i)%m)
b.sort()
b+=[-1]
a=x=1
for i in range(n):
  if b[i]==0:a+=1
  if b[i]!=b[i+1]:
    a+=x*(x-1)//2
    x=1
  else:x+=1
print(a-1)