import Control.Monad

main = do
  n <- getLine
  let n2 = read n :: Int
  ss <- replicateM n2 getLine
  let s = map (map strToInt) (map words ss)
      c = column $ map partSum s
      maxs = map maxPart c
      ans = foldl1 max maxs
  putStrLn $ show ans

strToInt :: String -> Int
strToInt str = read str

partSum :: [Int] -> [Int]
partSum [] = []
partSum (x:xs) = scanl1 (+) (x:xs) ++ (partSum xs)

column :: [[Int]] -> [[Int]]
column [] = []
column xs = foldr (zipWith (:)) [ [] | _ <- head xs] xs

maxPart :: [Int] -> Int
maxPart [] = 0
maxPart xs = foldl1 max $ scanl1 fsum xs
              where fsum a b
                      |a < 0     = b
                      |otherwise = a + b