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+1)] 
for i in range(1,N+1):
    SumH[i] = (SumH[i-1]+H[i-1])%M
Ctr = [-1 for i in range(N+1)]
Ans = [0 for i in range(N+1)]
for i in range(N+1):
    if SumH[i] in Ctr:
        continue
    Ctr[i] = SumH[i]
    Ans[i] = (SumH.count(SumH[i]))
for i in range(N+1):
    Ans[i] = Ans[i]*(Ans[i]-1)//2
print(sum(Ans))