from collections import defaultdict

N,M=map(int,input().split())
A=list(map(int,input().split()))
B=[0]*(N+1)
C=defaultdict(int)
C[0]+=1
for i in range(N):
    B[i+1]=(B[i]+A[i])%M
    C[B[i+1]]+=1
ans=0
for i in C.values():
    ans+=i*(i-1)//2
print(ans)
