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

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

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

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

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