let rec for_obvious acc s = function
  | [] -> acc, false
  | b::bs -> if b > s then (acc, true) else for_obvious (b::acc) (s - 1) bs

let rec dfs ans left bs s n =
  if bs = [] && left = [] then Some ans
  else if s > n then None
  else
    begin
      match bs with
      | [] -> Some ans
      | b::bs -> 
         if b > s then None
         else if b = s then 
           begin
             match dfs (b::ans)
                     [] (List.fold_left (fun acc l -> l::acc) bs left)
                     1 (n - 1) with
             | None -> dfs ans (b::left) bs (s + 1) n
             | Some ans -> Some ans
           end
         else dfs ans (b::left) bs (s + 1) n
    end

let _ =
  let n = Scanf.scanf "%d\n" (fun n -> n) in
  let bs = ref [] in
  for i = 0 to n - 1 do
    Scanf.scanf (if i <> n - 1 then "%d " else "%d\n") (fun b -> bs := b::!bs)
  done;
  let ls, flag = for_obvious [] n !bs in
  if flag then print_int (-1)
  else
    dfs [] [] ls 1 n 
    |> (function | None -> print_int (-1) 
                 | Some ans -> List.iter (fun n -> print_endline @@ string_of_int n) ans)
