N,M = list(map(int,input().split()))
A = list(map(int,input().split()))
count = 0
for i in range(N+1):
    for t in range(N+1):
        if i<t:
            count+=1 if sum(A[i:t])%M==0 and sum(A[i:t]) != 0 else  0
print(count)
