let print_list l =
  List.map string_of_int l |> String.concat " " |> print_endline;;

let () =
  let ct = ref 0 in
  let insertion_sort a n g =
    for i = g to n-1 do
      let v = a.(i) in
      let rec loop j =
        if j < 0 || a.(j) <= v then a.(j+g) <-v
        else begin a.(j+g) <- a.(j);incr ct;loop (j-g) end
      in loop (i - g)
    done;
  in
  let n = read_int () in
  let rec gen g b =
    let b2 = ceil ((float_of_int b)*.2.25+.1.) |> int_of_float in
    if b2 > n then g
    else gen (b2::g) b2
  in
  let a = Array.init n (fun x -> read_int ()) and
      g = gen [] 0 in
  let m = List.length g in
  let rec loop = function
      [] -> print_int m;print_newline ();
            print_list g;
            print_int !ct;print_newline ();
            Array.iter (fun x -> print_int x;print_newline ()) a
    | h::t ->insertion_sort a n h;loop t
  in loop g
;;