{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array
import Data.Array.Unboxed
import Control.Monad.ST
import Data.Array.ST

main :: IO ()
main = do
  n <- readLn :: IO Int
  ss <- fmap (map read . words) getLine :: IO [Int]
  let ans = solve ss
  if isNothing ans
    then putStrLn "-1"
    else putStr . unlines . map show $ fromJust ans

solve = go [] 
  where
    go as [] = Just as
    go as ss 
      | null v = Nothing
      | otherwise = go (s:as) $ unins s ss 
      where
        v = vanishable ss
        s = last v

vanishable :: [Int] -> [Int] 
vanishable ss = map fst . filter (\(i, j) -> i == j) $ zip ss [1..]

ins :: Int -> [Int] -> [Int]
ins a as = let (l, r) = splitAt (a - 1) as
           in l ++ [a] ++ r
unins :: Int -> [Int] -> [Int]
unins a as = let (l, r) = splitAt a as
             in (init l) ++ r
