
import Debug.Trace
import Data.Array
import Data.List
import qualified  Data.Sequence as S
import Data.Tuple

type Data = [(Int,Int)]

get :: IO (Int, Data)
get = do
  n <- read <$> getLine
  d <- (zip [1..n] . map read . words) <$> getLine
  pure (n, d)

post :: Array Int Int -> IO ()
post a = putStrLn $ concat $ intersperse "\n" $ map show $ elems a 

solve :: (Int, Data) -> Array Int Int
solve (n, d) = go (listArray (1,n) $ repeat 0) (array (1,n) d) where

  maximumLWithIndex :: Array Int Int -> (Int, Int)
  maximumLWithIndex = foldl1 f . assocs where
    f (i,x) (j,y)
      | x == y = (i,x)
      | x > y = (i,x)
      | x < y = (j,y)

  maximumRWithIndex :: Array Int Int -> (Int, Int)
  maximumRWithIndex = foldl1 f . assocs where
    f (i,x) (j,y)
      | x == y = (j,y)
      | x > y = (i,x)
      | x < y = (j,y)

  go :: Array Int Int -> Array Int Int -> Array Int Int
  go c d = 
    if x > 0 then
      go (c // [(i, (c ! i) + 1)]) (d // [(j, y - 1)])
    else
      c
    where
      (i,x) = maximumLWithIndex d
      (j,y) = maximumRWithIndex d

--solve' :: (Int, Data) -> Data
solve' (n, d) = solve'' cs ls
  where
    ls = sortBy (\a b -> compare b a) $ map swap d

    cs = listArray (1,n) $ repeat 0

    solve'' cs ls =
        if 0 == (fst $ last ls) then
          cs
        else if all (\a -> fst a == 1) ls then
          cs'
        else
          solve'' cs' ls''
      where
        x = maxL ls
        x' = maxR ls
        ls' = dropWhile (\a -> fst x == fst a) ls
        y = if length ls' > 0 then maxL ls' else maxL ls
        xs = takeWhile (\a -> fst x == fst a) ls
        xs' = map (\a -> (fst a - (fst a - fst y), snd a)) xs
        cs' = cs // 
          [(snd x', (cs ! snd x') + if length xs' == 1 then (fst x - fst y) else length xs')]
        ls'' = xs' ++ ls'


        maxL :: [(Int,Int)] -> (Int,Int)
        maxL (x:xs) = go x xs where
          go x [] = x
          go x (x':xs)
            | fst x == fst x' && snd x > snd x' = go x xs
            | fst x == fst x' && snd x < snd x' = go x' xs
            | fst x == fst x' = go x xs
            | fst x > fst x' = x
            | fst x < fst x' = go x' xs

        maxR :: [(Int,Int)] -> (Int,Int)
        maxR (x:xs) = go x xs where
          go x [] = x
          go x (x':xs)
            | fst x == fst x' && snd x > snd x' = go x' xs
            | fst x == fst x' && snd x < snd x' = go x xs
            | fst x == fst x' = go x xs'
            | fst x > fst x' = x
            | fst x < fst x' = go x' xs

main = do
  post =<< (solve <$> get)
