

fun main(args:Array<String>):Unit {
    val n = readLine()!!.toInt()
    val mat = Array(n + 1){Array(n + 1){0}}
    for (i in 1 .. n) {
        readLine()!!.split(' ').map(String::toInt).forEachIndexed { index, j -> mat[i][index + 1] = j }
    }
    for (i in 1 .. n) for (j in 1 .. n) mat[i][j] += mat[i - 1][j] + mat[i][j - 1] - mat[i - 1][j - 1]
    println((0 until n).map{
        left ->
        ((left + 1) .. n).map{
            right ->
            (0 until n).map{
                top ->
                ((top + 1) .. n).map{bottom -> mat[bottom][right] - mat[top][right] - mat[bottom][left] + mat[top][left]}.max()!!
            }.max()!!
        }.max()!!
    }.max()!!)
}
