let N = stdin.ReadLine() |> int

let B = stdin.ReadLine().Split() |> Array.map int

B |> Array.indexed |> Array.filter (fun (a, b) -> a-1 = b) |> printfn "%A"

let items =
    let rec loop i b =
        if i = N then
            []
        else
            let bx = b |> Array.indexed |> Array.filter (fun (a, b) -> a+1 = b)
            if Array.isEmpty bx then
                [-1]
            else
                let target = Array.last bx
                let j = fst target
                let x = snd target
                x :: loop (i+1) (Array.append b.[0..j-1] b.[j+1..]) 
    loop 0 B

if items |> Seq.exists ((=) -1) then do
    stdout.WriteLine -1
else
    for x in items |> List.rev do
        stdout.WriteLine x