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