import Control.Applicative
import Control.Monad
import Data.List

main :: IO ()
main = do
  n <- readLn
  ass <- replicateM n $ map read . words <$> getLine :: IO [[Int]]
  let ss = (replicate (n+1) 0 :) $ map (0:) $ transpose $ map (scanl1 (+)) $ transpose $ map (scanl1 (+)) ass
  print $ maximum [ss!!k!!l-ss!!i!!l-ss!!k!!j+ss!!i!!j | i <- [0..n], j <- [0..n], k <- [i+1..n], l <- [j+1..n]]