N, M = map(int, input().split())
treat = list(map(int, input().split()))
count = 0
for n in range(N):
    for m in range(n, N):
        if sum(treat[n:m+1]) % M == 0:
            count += 1


print(count)