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

print(num)
        
