N, M = map(int,input().split())
A=[int(i) for i in input().split()]
B=[0,]
s=0
s2=0
for i in range(N):
    s+=A[i]
    B.append(s)
    for j in range(i+1):
        if (s-B[j])%M==0:
            s2+=1
print(s2)
