#include <cstdio>
#include <algorithm>
#include <climits>
#include <cstring>
using namespace std;
int matrix[101][101], temp[101];

int N;

int kadane(int* start,
           int* finish)
{
    int sum = 0, maxSum = INT_MIN, i;

    *finish = -1;

    int local_start = 0;

    for (i = 0; i < N; ++i)
    {
        sum += temp[i];
        if (sum < 0) {
            sum = 0;
            local_start = i + 1;
        }
        else if (sum > maxSum)  {
            maxSum = sum;
            *start = local_start;
            *finish = i;
        }
    }


    if (*finish != -1)
        return maxSum;

    maxSum = temp[0];
    *start = *finish = 0;

    for (i = 1; i < N; i++)
    {
        if (temp[i] > maxSum)
        {
            maxSum = temp[i];
            *start = *finish = i;
        }
    }
    return maxSum;
}


void findMaxSum()
{
    // Variables to store the final output
    int maxSum = INT_MIN, finalLeft, finalRight,
        finalTop, finalBottom;

    int left, right, i;
    int sum, start, finish;

    // Set the left column
    for (left = 0; left < N; ++left) {
        memset(temp, 0, sizeof(temp));

        for (right = left; right < N; ++right) {


            for (i = 0; i < N; ++i)
                temp[i] += matrix[i][right];

            sum = kadane(&start, &finish);


            if (sum > maxSum) {
                maxSum = sum;
                finalLeft = left;
                finalRight = right;
                finalTop = start;
                finalBottom = finish;
            }
        }
    }
    printf("%d\n", maxSum);
}



int main(){
    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) scanf("%d", &matrix[i][j]);
    }
    findMaxSum();

    return 0;
}



