N, M = map(int, input().split(" "))
A = list(map(int, input().split(" ")))
R = [0] * (N+1)

ans = 0
temp = 0

for i in range(N):
    R[i+1] = temp + A[i]
    temp = R[i+1]

for j in range(1,N+1):
    for d in range(1,N+1):
        if j - d >= 0:
            if (R[j] - R[j-d]) % M == 0:
                ans += 1
print(ans)