#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>

#define MAX 1000000000
#define MIN -10000000000

#define ll long long

using namespace std;
int main() {

        int n,k,i,j,c,b,temp,last;
        ll tempsum,maxx;
        cin>>n;
        vector<vector<int> > a(n,vector<int>(n));
        vector<vector<ll> > s(n+1,vector<ll>(n+1,0));
    for(i=0;i<n;i++){
            for(j=0;j<n;j++){
                cin>>a[i][j];
            }
        }
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            s[i+1][j+1]=s[i+1][j]+a[i][j];
        }
    }


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

    maxx=a[0][0];
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            for(c=0;c<=i;c++){
                for(b=0;b<=i;b++){
                   // cout << s[i+1][j+1]-s[i+1][b]-s[c][j+1]+s[c][b]<< endl;
                   maxx=max(s[i+1][j+1]-s[i+1][b]-s[c][j+1]+s[c][b],maxx);
                }
            }
        }
    }

cout << maxx << endl;



//cout << "aaa" << endl;

    return 0;
}
