#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

int n, a[100][100], b[101], tate[101][101];

int main(){
	cin >> n;
	rep(i, n) rep(j, n){
		cin >> a[i][j];
		tate[i + 1][j] = tate[i][j] + a[i][j];
	}
	int mx = -2 * inf;
	
	rep(j, n) rep(i, j + 1){
		memset(b, 0, sizeof(b));
		rep(k, n) b[k + 1] = b[k] + tate[j + 1][k] - tate[i][k];
		
		rep(l, n) rep(k, l + 1) mx = max(mx, b[l + 1] - b[k]);
	}
	cout << mx << endl;
	
	return 0;
}