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[SumH[i]] = 1
    else:
        Ans[SumH[i]] += 1
ans = 0
for i in Ctr:
    ans += Ans[i]*(Ans[i]-1)//2
print(ans)
