type ps = PS of ps * int * int | L of int

let n, q = Scanf.scanf "%d %d\n" (fun x y -> x, y)

let rec rev_read_ints accu = function
  | 0 -> accu
  | k -> rev_read_ints ((Scanf.scanf "%d\n" (fun x -> x)) :: accu) (k-1)

let qs = List.rev (rev_read_ints [] q)

let rec app state q = match state with
  | L k -> if q <= k then L q else PS (state, k, q)
  | PS (p, pl, l) -> if q > l then PS (state, l, q) else if q >= pl then PS (p, pl, q) else app p q

let result = List.fold_left app (L n) qs

let rec count = function
  | L k -> let a = Array.make n 0 in for i = 0 to k-1 do a.(i) <- 1 done; a
  | PS (p, pl, l) -> let a = Array.map (( * ) (l/pl)) (count p) in let aa = count (app p (l mod pl)) in
    begin for i = 0 to n-1 do aa.(i) <- aa.(i) + a.(i) done; aa end

let () = Array.iter (fun x -> Printf.printf "%d\n" x) (count result)