#include <iostream>
#include <vector>
#include <string>

using namespace std;

struct Data {
    int** data;
};

vector<string> split(string s, string c) {
    vector<string> ret;
    for (int i = 0, n; i <= s.length(); i = n + 1) {
        n = s.find_first_of(c, i);
        if (n == string::npos) {
            n = s.length();
        }
        string tmp = s.substr(i, n - i);
        ret.push_back(tmp);
    }
    return ret;
}

int partial_sum(int i, int j, Data* d) {
    int sum = 0;
    for (int k = 0; k <= i; k++) {
        for (int l = 0; l <= j; l++) {
            sum += d->data[k][l];
        }
    }
    return sum;
}

int** precompute(int n, Data* d) {
    int** memo = new int*[n];
    for (int i = 0; i < n; i++) {
        memo[i] = new int[n];
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            memo[i][j] = partial_sum(i, j, d);
        }
    }
    return memo;
}

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

    int** data = new int*[n];
    for (int i = 0; i < n; i++) {
        data[i] = new int[n];
    }

    Data d;
    d.data = data;

    for (int i = 0; i < n; i++) {
        string strRow = "";
        getline(cin, strRow);
        vector<string> row = split(strRow, " ");
        for (int j = 0; j < row.size(); j++) {
            data[i][j] = stoi(row[j]);
        }
    }

    int** memo = precompute(n, &d);

/*
    cout << endl << endl;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cout << memo[i][j] << " ";
        }
        cout << endl;
    }
*/

    long max = -1000000000000;

    long sum = 0;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            for (int k = i; k < n; k++) {
                for (int l = j; l < n; l++) {
                    if (i == 0 && j == 0) {
                        sum = memo[k][l];
                    } else if (i == 0) {
                        sum = memo[k][l] - memo[k][j - 1];
                    } else if (j == 0) {
                        sum = memo[k][l] - memo[i - 1][l];
                    } else {
                        sum = memo[k][l] - memo[i - 1][l] - memo[k][j - 1] + memo[i - 1][j - 1];
                    }
                    max = sum > max ? sum : max;
                }
            }
        }
    }

     cout << max << endl;
}