#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int IINF = INT_MAX;
#define REP(i, n) for (int i = 0; i < n; i++)

int main() {
    int n, a[105][105]{}, ans = -IINF;
    cin >> n;
    REP(i,n)REP(j,n){
        cin >> a[i+1][j+1];
        a[i+1][j+1] += a[i+1][j] + a[i][j+1] - a[i][j];
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            for(int k=i+1;k<=n;k++){
                for(int l=j+1;l<=n;l++){
                    ans = max(ans, a[k][l] - a[k][j] - a[i][l] + a[i][j]);
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}
