import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    n <- getInt
    bs <- getIntList
    let ans = reverse $ solve n (reverse bs)
    if any (== 0) ans then
        print (-1)
    else mapM_ print ans

solve 0 _ = []
solve k rs | i == 0 = [0]
           | otherwise = i : solve (k-1) (map snd (xs ++ tail ys))
    where (xs,ys) = span (\(i,b) -> i /= b) (zip [k,k-1..] rs)
          i = length ys