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

An = list(map(int, input().split()))

An = [0]+An

#print(An)

for i in range(n):
    An[i+1] += An[i]

#print(An)

ans = 0
for i in range(n):
    for j in range(i, n): 
#        print((i,j))
        t = An[j+1]-An[i]

        ans += 1 if t%m == 0 else 0


print(ans)