N,M=map(int,input().split())
A=list(map(int,input().split()))
accumA=[]
tmp=0
for i in range(len(A)):
  tmp+=A[i]
  accumA.append(tmp)

accumA=[0]+accumA
cnt=0
for i in range(1,N):
  for j in range(i,N+1):
    s=accumA[j]-accumA[i-1]
    if s%M==0:
      cnt+=1

print(cnt)