import Control.Applicative ((<$>))
import Control.Monad (replicateM)


solve :: Int -> [[Int]] -> Int
solve a [] = a
solve a as@(xs:xss) =
  if mod a (sum xs) == 0
    then solve a xss
    else solve (a + 1) as

main = do
  n <- read <$> getLine :: IO Int
  ls <- fmap words <$> replicateM n getLine
  let xss = fmap (\l -> fmap read l) ls :: [[Int]] in
    putStrLn . show $ solve (sum . head $ xss) (tail xss)
