N,M = map(int,input().split())
L = list(map(int,input().split()))
ans = 0
for i in range(N) :
    for j in range(i+1,N+1) :
        K = list(L[i:j])
        k = sum(K)
        if k % M == 0 :
            ans += 1
            #print(k)
print(ans)
    