N,M = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

stim_A = [0]
for ind,i in enumerate(A):
    stim_A.append((stim_A[-1]+i)%M)

ans = 0
for ind,i in enumerate(stim_A[1:]):
    ans += 1 if i==0 else 0
    ans += stim_A[1:ind+1].count(i)
print(ans)