main = do
  n <- readLn
  bs <- map read.words<$>getLine
  putStr.unlines.map show $ solve n bs

solve n bs
  | head ans == -1 = [-1]
  | otherwise = ans
  where
  ans = reverse.go n.reverse$bs
  go _ [] = []
  go n bs
    | del == -1 = [-1]
    | otherwise = del : go (n-1) remaining
    where
    del = find n bs
    remaining = take (n-del) bs ++ drop (n-del+1) bs
    find _ [] = -1
    find i (b:bs)
      | i == b = i
      | otherwise = find (i-1) bs