N,M = [int(i) for i in input().split()]
H = [int(i) for i in input().split()]
for i in range(N):
    H[i] = H[i]%M
SumH = [0]
for i in range(N):
    SumH.append((SumH[i]+H[i])%M)
Ctr = []
Ans = []
for i in range(N+1):
    if SumH[i] not in Ctr:
        Ctr.append(SumH[i])
        Ans.append(int((SumH.count(SumH[i]))*(SumH.count(SumH[i])-1)/2))
print(sum(Ans))