N, M = map(int, input().strip().split())
A = list(map(int, input().strip().split()))
count = 0
for i in range(N):
    for j in range(i, N):
        if sum(A[i: j + 1]) % M == 0:
            count += 1

print(count)