module P = Map.Make(struct type t = int let compare = (-) end)
let () =
  Scanf.scanf "%d %d" @@ fun n m ->
  let a = Array.init n (fun _ -> Scanf.scanf " %d" ((+) 0)) in
  Array.fold_left (fun ((c, mp), z) x ->
    let s = try P.find ((c + x) mod m) mp with Not_found -> 0 in
    ((c + x) mod m, P.add ((c + x) mod m) (s+1) mp), z+s
  ) ((0, P.singleton 0 1), 0) a |> snd |> Printf.printf "%d\n"