n, m = [int(item) for item in input().split()]
a = [int(item) for item in input().split()]

cumsum = [0] * n
for i in range(n):
  if i == 0:
    cumsum[i] = a[i]
  else:
    cumsum[i] = cumsum[i-1] + a[i]
    
ans = 0
for l in range(n):
  for r in range(l, n):
    if (cumsum[r] - cumsum[l-1]) % m == 0:
      ans += 1
      
print(ans)