import numpy as np
N, M = map(int, input().split())
A = []
res = 0
for i in input().split():
    A.append(int(i))
    if A[-1]%M==0:
        res += 1
ar = np.eye(N) * A

for h in range(0, N):
    for w in range(1, h+1):
        ar[-h-1, -h-1+w] = ar[-h, -h-1+w] + ar[-h-1, -h-2+w] - ar[-h, -h-2+w]
        if ar[-h-1, -h-1+w] % M == 0:
            res += 1
# print(int(sum(sum(ar % M == 0)) - sum(np.linspace(1, N-1, N-1))))
print(res)