from collections import Counter
N,M=map(int,input().split())
A=list(map(int,input().split()))

B=[0]*(N+1)
for i in range(1,N+1):
  B[i]=(B[i-1]+A[i-1])%M
  
B=Counter(B).values()
ans=0
for b in B:
  ans+=b*(b-1)//2
  
print(ans)