N, M = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
for i in range(1,len(A)+1):
    for j in range(len(A)):
        ij_sum = sum(A[j:i])
        if ij_sum != 0 and ij_sum % M == 0:
            ans += 1
print(ans)