#include <iostream>

using namespace std;

typedef long long ll;

const int MAX_N = 102;
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];

   ll ans = sum[0][0];
   for (int y1 = 0; y1 < n; ++y1) {
       for (int y2 = y1; y2 < n; ++y2) {
           ll v = -1e9;
           for (int x = 0; x < n; ++x) {
               ll area = sum[y2][x];
               if (x != 0)
                   area -= sum[y2][x - 1];
               if (y1 != 0)
                   area -= sum[y1 - 1][x];
               if (x != 0 && y1 != 0)
                   area += sum[y1 - 1][x - 1];

               v = (area > v) ? area : v + area;
               ans = max(ans, v);
           }
       }
   }
   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;
}