N,M = list(map(int,input().split()))

A = list(map(int,input().split()))
s = 0
S = [0]
for i in range(N):
    s+=A[i]
    s=s%M
    S.append(s)

from collections import Counter

c = Counter(S)
count=0
for i in c.keys():
    count+=((c[i]-1)*c[i])//2

print(count)