n = gets.split.map {|e| e.to_i }.first
$bs = gets.split.map {|e| e.to_i }
cs = $bs.sort.reverse

def f(as, xs, ys)
  # p [as, xs, ys]
  if as.size == 0
    if ys == $bs
      puts xs
      exit
    end
  else
    as.size.times { |i|
      x = as[i]
      if x <= xs.size + 1
        f(as[0...i] + as[i+1..-1], xs + [x], ys[0...x-1] + [x] + ys[x-1..-1])
      end
    }
  end
end

f(cs, [], [])
puts -1
