n,m=map(int,input().split())
ar=list(map(int,input().split()))
ans=0
for i in range(0,len(ar)):
    sum=0
    for j in range(i,len(ar)):
        sum+=ar[j]
        if sum%m==0:
            ans+=1
print(ans)