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

count = 0
for i in range(1, len(A) + 1):
    for j in range(0, len(A) - i + 1):
        if sum(A[j:j+i]) % M == 0:
            count += 1
print(count)
