import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.Vector as V

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

main = do
    d <- getInt
    cs <- VU.fromList <$> getIntList
    ss <- V.fromList . map VU.fromList <$> replicateM d getIntList
    let ts = VU.create $ do
            vec <- VUM.replicate d (0 :: Int)
            forM_ [0..d-1] $ \day -> do
                let con = ss V.! day
                let t = snd . VU.maximum $ VU.imap (\i c -> (c,i)) con
                VUM.write vec day t
            return vec
              
    let result = VU.create $ do
             sat <- VUM.replicate (d+1) (0 :: Int)
             ld <- VUM.replicate 26 (0 :: Int)
             decs <- VUM.replicate 26 (0 :: Int)
             forM_ [1..d] $ \day -> do
                 let contest = ts VU.! (day - 1)
                 let inc = ss V.! (day - 1) VU.! contest
                 VUM.write ld contest day
                 forM_ [0..25] $ \con -> do
                     let dec = cs VU.! con
                     lday <- VUM.read ld con
                     VUM.write decs con $ dec * (day - lday)
                 s <- VUM.read sat (day - 1)
                 VUM.write sat day (s + inc)
                 forM_ [0..25] $ \con -> do
                     dec <- VUM.read decs con
                     VUM.modify sat (subtract dec) day
             return sat
    VU.mapM_ print $ VU.tail result