# coding: utf-8

list = input().split()
N = int(list[0])
M = int(list[1])
a = input().split()
hako = []
for i in a:
    hako.append(int(i))

ans = 0
for i in range(N):
    for j in range(N - i):
        if sum(hako[i:i+j+1]) % M == 0:
            ans += 1
print(ans)