N, M =map(int, input().split())
A = list(map(int, input().split()))

S = [0]
for i in range(N):
    S.append(A[i]+S[i])

pS = []
for j in range(N):
    for k in range(j, N):
        pS.append((S[k+1]-S[j])%M==0)

print(sum(pS))