#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second

static const double PI=6*asin(0.5);
typedef pair<double,double> P;
typedef complex<double> CP;
typedef long long ll;


ll a[110][110]={0};

int main(){
	int n;
	cin>>n;
	rep(i,n){
		rep(j,n){
			cin>>a[i+1][j+1];
		}
	}
	ll res=-10000;
	
	rep(i,n){
		rep(j,n){
			a[i+1][j+1]+=a[i+1][j]+a[i][j+1]-a[i][j];
		}
	}
	rep(i,n){
		rep(j,n){
			for(int s=i;s<n;s++){
				for(int t=j;t<n;t++){
					res=max(res,a[s+1][t+1]-a[i][t+1]-a[s+1][j]+a[i][j]);
				}
			}
		}
	}
	cout<<res<<endl;
	return 0;
}