from collections import Counter
N,M = map(int,input().split())
L = list(map(int,input().split()))

A = [0]
for i in range(N) :
    a = (A[-1]+L[i])%M
    A.append(a)

B = Counter(A)
ans = 0
for i in B.values() :
    ans += i*(i-1)//2 #Combination iC2
print(ans)
