N, M= map(int, input().strip().split(' '))
A_lst = list(map(int, input().strip().split(' ')))

pyramid = [[] for i in range(len(A_lst)+1)]
pyramid[0] = [0 for i in range(len(A_lst)+1)]
pyramid[1] = A_lst

count = 0

for i in range(2, len(pyramid)):
    for j in range(len(A_lst) - i + 1):
        new_elem = pyramid[i-1][j] + pyramid[i-1][j+1] - pyramid[i-2][j+1]
        pyramid[i].append(new_elem)
        if new_elem % M == 0 and new_elem != 0:
            count += 1

for elem in A_lst:
    if elem % M == 0 and elem != 0:
        count += 1

print(count)