import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val cumsum = Array(n+1) { IntArray(n+1) }
    for (y in 1..n) {
        var subtotal = 0
        for (x in 1..n) {
            subtotal += sc.nextInt()
            cumsum[y][x] = subtotal + cumsum[y-1][x]
        }
    }

    var result = -10000000
    for (y in 1..n) {
        for (x in 1..n) {
            for (x2 in x-1 downTo 0) {
                for (y2 in y-1 downTo 0) {
                    result = Math.max(result, cumsum[y][x] - cumsum[y2][x] - cumsum[y][x2] + cumsum[y2][x2])
                }
            }
        }
    }
    println(result)
}
