import itertools
N,M=map(int,input().split())
def f(x):
  return int(x)%M
A=[0]+list(map(f,input().split()))
A = list(itertools.accumulate(A))
ans=0
for j in range(1,N+1):
  for i in range(N+1-j):
    if (A[i+j]-A[i])%M==0:
      ans+=1
print(ans)