N,M = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
count=0
for j in range(N):
    B = [sum(A[j:i+1]) % M for i in range(j,N)]
    for k in B:
        if k == 0:
            count += 1
print(count)