from collections import Counter
N,M=map(int,input().split())
A=[0]+list(map(int,input().split()))
for i in range(1,N+1): A[i] = (A[i]+A[i-1])%M
cnt = Counter(A)
print(sum(n*(n-1)//2 for n in cnt.values()))
