N,M = map(int,input().split())
A = list(map(int,input().split()))
counter = 0
#for i in range(len(A)) :
#    A[i] = A[i] % M
for j in range(len(A)) :
    P = 0
    for k in range(j,N) :
        P += A[k]
        if P % M == 0 :
            counter += 1
print(counter)

