n, m = map(int, input().split())
a = map(int, input().split())
map = {}
ans = 0
for i in a:
  nextMap = {}
  for k, v in map.items():
    nextMap[(i + k) % m] = v
  nextMap[i % m] = nextMap[i % m] + 1 if i % m in nextMap else 1
  if 0 in nextMap: ans += nextMap[0]
  map = nextMap
print(ans)