N = (gets).to_i
bs = (gets).split(" ").map {|i| i.to_i}

# check
def condition_chk(arr)
  #p arr
  arr.each.with_index do |b,i|
    if (b > i+1) then
        return false
    end
  end
  return true
end

# 作ってみる
# １で分割すると良い気がする
arr = []
an = 0
bs.each_with_index do |b,i|
    an = an + 1 if (b==1 && i>0)
    arr[an] = [] if arr[an].nil?
    arr[an] << b
end

A = an
isOK = true
res = []
an.downto(0) do |n|
    if not condition_chk(arr[n]) then
        isOK = false
        break
    end
    (arr[n].sort).each do |a|
        res << a
    end
end

if isOK then
    puts res
else
    puts "-1"
end