matrix = Array.new(n = $<.gets.to_i) {$<.gets.split.map(&:to_i)}
max = 0
memo = {}

try = ->(x, y, w, h) {
  return 0 if x >= n or y >= n or w <= 0 or h <= 0
  return matrix[y][x, w].sum if h == 1
  return (y..y + h - 1).map {|i| matrix[i][x]}.sum if w == 1
  key = "#{x},#{y},#{w},#{h}"
  return memo[key] if memo[key]
  
  n1 = try.(x, y + 1, w, h - 1)
  n2 = try.(x, y    , w, h - 1)
  n3 = try.(x + 1, y, w - 1, h)
  n4 = try.(x    , y, w - 1, h)
  
  num = try.(x, y, w, 1) + n1
  max = num if num > max
  memo[key] = num
}
try.(0, 0, n, n)

puts max

