#include <iostream>
#include <string>

using namespace std;

int A[101][101];

int main() {
    int n;
    cin >> n;

    fill(A[0], A[101], 0);

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> A[i + 1][j + 1];
        }
    }

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            A[i][j] = A[i][j] + A[i - 1][j] + A[i][j - 1] - A[i - 1][j - 1];
        }
    }

    int ans = -100000001;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            for (int ii = i + 1; ii <= n; ii++) {
                for (int jj = j + 1; jj <= n; jj++) {
                    ans = max(ans, A[ii][jj] - A[i][jj] - A[ii][j] + A[i][j]);
                }
            }
        }
    }

    cout << ans << endl;
}
