let make_list f t step =
  let rec make_list_inner c t lst =
    if c >= t then lst else make_list_inner (c+step) t (c::lst)
  in
  List.rev (make_list_inner f t [])

let process lst x =
  match lst with
    [] -> (0, [x])
  | hd::rest ->
     match x with
       0 -> (hd, rest)
     | _ -> (0, x::hd::rest)
    
let () =
  let rec read lst =
    try let (poped, new_lst) = (Scanf.scanf "%d\n" (process lst)) in
        if poped > 0 then (Printf.printf "%d\n" poped) else ();
        read new_lst
    with End_of_file ->
         ()
  in
  read []
;;