N,M=[int(i) for i in input().split()]
s=0
A=[int(i) for i in input().split()]
for i in range(0,len(A)):
    for j in range(i,len(A)):
        B=A[i:j+1]
        P=sum(B)
        if P%M==0:
            s+=1
print(s)