n = gets.to_i
a = (1..n).map{ gets.split.map(&:to_i) }
accum = a.map{|row|
    row.inject([0]){|s, x| s + [s[-1] + x]} 
}

max = 0 
(1..n).to_a.repeated_combination(2){|i, j|
    sum = 0 
    (0..n-1).each{|k|
        sum += accum[k][j] - accum[k][i-1]
        max = sum if sum > max
        sum = 0 if sum < 0
    }
}

a.flatten!
p a.any?{|x| x >= 0} ? max : a.max