N,M=map(int,input().split())
L=list(map(int,input().split()))
R=[0]
sums=0
for i in L:
  sums+=i
  R.append(sums)
ans=0
for i in range(N):
  for j in range(i,N):
    if (R[j]-R[i-1])%M==0:
      ans+=1
print(ans)