N,M = map(int,input().split())
*A, = map(int,input().split())
S = [0]*(N+1)
for i in range(N):S[i+1]=(S[i]+A[i])%M
ans = 0
c = {}
for s in S:c[s] = c.get(s,0)+1
for n in c.values():ans+=n*(n-1)//2
print(ans)