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