#D問題
N,M=map(int,input().split())
A=list(map(int,input().split()))
rui=[0]
for i in range(N):
    rui.append(rui[-1]+A[i])
count=0
for l in range(N):
    for r in range(N-l):
        R=l+r+1
        ran=rui[R]-rui[l]
        if ran%M == 0:
            count+=1
print(count)