#include <iostream>
#include <climits>

using namespace std;

typedef long long ll;

const int MAX_N = 110;
ll a[MAX_N][MAX_N];
ll sum[MAX_N][MAX_N];
int n;

void solve()
{
    sum[0][0] = a[0][0];
    for (int i = 1; i < n; ++i) {
        sum[0][i] = sum[0][i - 1] + a[0][i];
        sum[i][0] = sum[i - 1][0] + a[i][0];
    }
    for (int i = 1; i < n; ++i)
        for (int j = 1; j < n; ++j)
            sum[i][j] = sum[i - 1][j] + sum[i][j - 1]
                - sum[i - 1][j - 1] + a[i][j];

    // (i, j)-(k, m)
    ll ans = -LONG_MAX;
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j)
            for (int k = i; k < n; ++k)
                for (int m = j; m < n; ++m)
                    ans = max(ans, sum[k][m]
                              - sum[i - 1][m] - sum[k][j - 1] + sum[i - 1][j - 1]);
    cout << ans << endl;
}

int main()
{
    cin >> n;
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j)
            cin >> a[i][j];

    if (n == 1)
        cout << a[0][0] << endl;
    else
        solve();

    return 0;
}