type 'a tree =
    Leaf
  | Node of 'a tree * 'a * 'a tree

let empty : 'a tree = Leaf
          
let rec insert : ('a -> 'b) -> 'a -> 'a tree -> 'a tree = fun f x t ->
  match t with
    Leaf -> Node (Leaf, x , Leaf)
  | Node (l, y, r) ->
     if f x < f y then
       Node (insert f x l, y, r)
     else
       Node (l, y, insert f x  r)

let rec print_tree_int t =
  match t with
    Leaf -> ()
  | Node (l, (x, i), r) ->
     print_tree_int l;
     print_int i;
     print_char ' ' ;
     print_tree_int r
                
let i_inp_list : unit -> (int * int) list = fun () ->
  let inp_split = Str.split (Str.regexp " ") (input_line stdin) in
  List.mapi (fun i x -> (int_of_string x, i + 1)) (inp_split)
  
let () =
  let _ = Scanf.sscanf (input_line stdin) "%d" (fun a -> a) in
  let l = i_inp_list () in
  let ans = List.fold_left (fun t x -> insert (fun (a, b) -> b) x t) empty l in
  print_tree_int ans;
  print_newline ()
