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

for i in range(1,n+1) :
   for j in range(i,n+1) :

      s = 0

      for k in range(i,j+1) :
         s = s + a[k-1]
      if s%m == 0 :
         t = t + 1

print (t)