import qualified Data.List as L

(&.) :: a -> (a -> b) -> b
(&.) x f = f x
infixl 0 &.

insertAt :: Int -> a -> [a] -> [a]
insertAt index x ls = let (first, second) = L.splitAt (index-1) ls in
  first ++ [x] ++ second

snd3 :: (a, b, c) -> b
snd3 (_, b, _) = b
thd3 :: (a, b, c) -> c
thd3 (_, _, c) = c

construct' :: [(Int, Int, Int)] -> [Int] -> [Int]
construct' [] result = result
construct' sortedList@((_,b,count):rest) result =
  let newResult = insertAt b b result in
      construct' rest newResult

construct :: [(Int, Int, Int)] -> [Int]
construct list = let sortedList = L.sortOn thd3 list in
  construct' sortedList []

-- solve :: Int -> [Int] -> [[(Int, Int, Int)]]
solve n bn =
  case L.permutations [1..n] -- [[Int]]
         &. map (\counts -> zip3 [1..] bn counts) -- counts :: [Int] -> [(Int, Int, Int)]
         &. filter (all $ \(index, b, count) -> b <= count && count <= n - index + b)
         &. L.find (\list -> construct list == bn) of
         Just list -> L.sortOn thd3 list &. map snd3
         Nothing -> []
           -- &. filter (\list -> construct list == bn)
           -- &. map (\list -> L.sortOn thd3 list &. map snd3)


main :: IO ()
main = do
  n <- readLn :: IO Int
  bn <- map read . words <$> getLine
  case solve n bn of
    [] -> putStrLn "-1"
    res -> mapM_ (putStrLn . show) res