gets
t = gets

a = t.split.map{|x| x.to_i}

if a[0] != 1
  puts "-1"
  exit
end

v = []
while a.size > 0
  j = 1
  flag = 0
  while j < a.size
    if (a[j] != j+1)
      v << a[j-1]
      a.delete_at(j-1)
      flag = 1
      break
    end
    j += 1
  end
  if flag == 0
    k = 0
    while k < a.size
      if (a[k] != k+1)
        puts "-1"
        exit
      end
      k +=1
    end
    a.each { |u|
      puts u
    }
    v.reverse.each { |u|
      puts u
    }
    exit
  end
end
