from collections import Counter
N,M = list(map(int,input().split()))
A = list(map(int,input().split()))
sum = [0]*(N+1)

for i in range(N):
    sum[i+1] = (sum[i] + A[i])%M
    

C = Counter(sum)
ans = 0
for k,v in C.items():
    ans += v*(v-1)//2

print(ans)