N, M=map(int, input().split())
A=list(map(int, input().split()))
s=[0 for _ in range(N+1)]
counts=[0 for _ in range(M)]
for i in range(N):
    s[i+1]=(s[i]+A[i])%M
ans=0
for i in range(N+1):
    ans+=counts[s[i]]
    counts[s[i]]+=1
print(ans)