n = gets.to_i
a = []
n.times do |i|
  a[i] = gets.split(" ").map(&:to_i)
end

max = nil
for is in 0..(n-1)
  for ie in (is+1)..(n-1)
    for js in 0..(n-1)
      for je in (js+1)..(n-1)
        sum = 0
        for it in is..ie
          for jt in js..je
            sum += a[jt][it]
          end
        end
        max = sum if max.nil? || max < sum
      end
    end
  end
end
puts max
