local n, m = io.read("*n", "*n")
local a = {}
a[0] = 1
local tot = 0
for i = 1, n do
  tot = (tot + io.read("*n")) % m
  if(a[tot] == nil) then a[tot] = 1 else a[tot] = a[tot] + 1 end
end
local sum = 0
for k, v in pairs(a) do
  if(2 <= v) then
    sum = sum + v * (v - 1) // 2
  end
end
print(sum)
