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