n,m=map(int,input().split())
a=list(map(int,input().split()))
b=[]
b.append(a[0])
for i in range(n-1):
  b.append(b[i]+a[i+1])

cnt=0
for i in range(n):
  if b[i]%m==0:
    cnt+=1
    
for i in range(n):
  for j in range(i+1,n):
    if (b[j]-b[i])%m==0:
      cnt+=1
      
print(cnt)