n, m = map(int, input().split())
a = list(map(int, input().split()))

sum_list = [0]
count = 0
for i in range(len(a)):
    sum_list.append(sum(a[:i+1]))
for i in range(n):
    for j in range(n-i):
        if (sum_list[i+j+1] - sum_list[i]) % m ==0:
            count += 1
print(count)