#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int d[120][120];
int memo[120][120];
int main(){
	int n;
	cin>>n;
	for(int i =1;i <= n;i++){
		for(int j =1;j <= n;j++){
			int x;
			cin>>x;
			d[i][j]=d[i-1][j]+d[i][j-1]-d[i-1][j-1]+x;
		}
	}
	int ans =-INF;
	for(int i =1;i <=n;i++){
		for(int j =1;j <=n;j++){
			for(int y =1;y <=i;y++){
				for(int x =1;x <=j;x++){
					ans =max(ans,d[i][j]-d[y-1][j]-d[i][x-1]+d[y-1][x-1]);
				}
			}
		}
	}
	cout <<ans<<endl;
	return 0;
}