#include <iostream>
#include <algorithm>
using namespace std;

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

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

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            for (int k = 1; k <= i; k++) {
                for (int l = 1; l <= j; l++) {
                    sum[i][j] += a[k][l];
                }
            }
        }
    }

    int maxi = sum[1][1];
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            //maxi = max(maxi, sum[i][j]);
            for (int k = 1; k <= i; k++) {
                for (int l = 1; l <= j; l++) {
                    int temp;
                    temp = sum[i][j] - sum[i][l - 1] - sum[k - 1][j] + sum[k - 1][l - 1];
                    maxi = max(maxi, temp);
                }
            }
        }
    }
    cout << maxi << endl;
    
    /*
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            cout << sum[i][j] << " ";
        }
        cout << endl;
    }
    */
    return 0;
}