n,m=map(int,input().split())
a=[int(x) for x in input().split()]
b=[0 for x in range(n+1)]

for i in range(1,n+1):
  b[i]=b[i-1]+a[i-1]

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

print(c)
