let ($) f g = fun x -> g (f x)
let split_string ?(pattern="") = Str.split @@ Str.regexp pattern
let n = Scanf.sscanf (read_line ()) "%d" @@ fun n -> n
let bs = read_line () |> split_string ~pattern:" " |> List.map int_of_string

let rec loop ans = function
  | [] -> ans |> List.map string_of_int |> String.concat "\n" |> print_endline
  | bs -> 
    let bs = List.mapi (fun i v -> (i + 1, v)) bs in
    let xs = bs |> List.filter (fun (i, v) -> i = v) in
    if List.length xs = 0 then print_endline "-1"
    else
      let (idx, v) = (List.rev $ List.hd) xs in
      loop (v :: ans) (bs |> List.filter (fun (i, _) -> i <> idx) |> List.map snd)

let () = loop [] bs