N,*A = `dd`.split.map &:to_i

def dig(as)
  return [] if as.size == 0
  (1..as.size).each{ |n|
    if as[n-1] == n
      res = dig(as[0...n-1]+as[n..-1])
      return res + [n] if res
    end
  }
  false
end

res = dig(A)
puts res ? res : -1