N,M = map(int,input().split())
A = list(map(int,input().split()))
k = [0]*(N+1)
sum = 0
l = [0]*N
ans = 0
p = 0
for i in range(N):
  sum += A[i]
  k[i+1] = sum
for i in range(1,N+1):
  for j in range(len(k)-i):
    l[j] = k[j+i]-k[j]
  for _ in range(len(l)):
    if l[_]%M == 0:
      ans += 1
  p += 1
  l = [0]*(N-p)
print(ans)