@N = gets.to_i
@B = gets.split.map(&:to_i)
@b = @B.join

r = Hash.new(0)
@N.times do |i|
  r[@B[i]] += 1
end

def b(p, b, r)
  if p.size == @N
    if @b == b.join
      p.each do |pp|
        puts pp
      end
      return true
    end

    return false
  end

  result = false

  r.each do |i, n|
    next if i > p.size + 1
    next if n == 0

    rd = r.dup
    rd[i] -= 1
    bd = b.dup

    pd = p.dup
    pd << i

    result = b(pd, bd.insert(i - 1, i), rd) || result
  end

  result
end


if r[1] == 0
  puts '-1'
else
  rd = r.dup
  rd[1] -= 1
  unless b([1], [1], rd)
    puts '-1'
  end
end