def dfs(b, ans)
#  puts "b:" + b.inspect + " ans:" + ans.inspect
  if b.empty?
    ans.each { |v| puts v }
    return true
  end
  done = false
  for i in 0...(b.length) do
    if b[i] == i + 1
      bb = b.dup
      ans.unshift(bb.delete_at(i))
      done = dfs(bb, ans)
      ans.shift
    end
    break if done
  end
  return done
end

n = gets.to_i
b = gets.split.map(&:to_i)
done = dfs(b, [])
puts -1 if !done
