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