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

S = [0 for k in range(N)]
S[0] = A[0]
for k in range(1,N):
    S[k] = S[k-1] + A[k]
S = [0] + S

for k in range(N+1):
    for l in range(k+1,N+1):
        if (S[l]-S[k])%M == 0:
            ans += 1
print(ans)