#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

signed main(){
	int n;
	cin>>n;
	int a[101][101]={};
	rep(i,1,n+1) rep(j,1,n+1) cin>>a[i][j];
	//int sum[101][101]={};
	rep(i,1,n+1){
		rep(j,2,n+1){
			a[i][j]+=a[i][j-1];
		}
	}
	rep(i,1,n+1){
		rep(j,2,n+1){
			a[j][i]+=a[j-1][i];
		}
	}
	int MAX=-1000000000;
	rep(y1,0,n+1){
		rep(y2,y1+1,n+1){
			rep(x1,0,n+1){
				rep(x2,x1+1,n+1){
					MAX=max(MAX,a[y2][x2]-a[y2][x1]-a[y1][x2]+a[y1][x1]);
				}
			}
		}
	}
	o(MAX);
}