n,m = map(int,input().split())
a = list(map(int,input().split()))

sum_s =[0]*n
sum_s[0]=a[0]
for i in range(1,n):
  sum_s[i] = (a[i]+ sum_s [i-1])%m

#print(sum_s)

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