mat = []
size = gets.chomp.to_i
size.times do
  mat.push gets.chomp.split.map(&:to_i)
end

max = mat[0][0]

size.times do |i|
  len = i + 1
  range = 0..(size - len)
  range.each do |y|
    range.each do |x|
      sum = 0
      len.times do |row|
        sum += mat[y + row].slice(x, len).inject(:+)
        max = sum if max < sum
      end
    end
  end
end

puts max