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

ans = 0
for i in A:
    if i % M == 0:
        ans += 1

for i in range(2, N+1):
    for j in range(N-i+1):
        if sum(A[j:j+i]) % M == 0:
            ans += 1

print(ans)
