#include <bits/stdc++.h>
using namespace std;

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
#define ALL(x) x.begin(),x.end()
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int N;
ll acc [101] [101];
const ll INF = 1e17;

int main()
{
	scanf("%d",&N);
	vector< vector<ll> > A(N,vector<ll>(N));
	FOR(i,0,N) FOR(j,0,N){
		scanf("%lld",&A [i] [j]);
	}
	FOR(i,0,N) FOR(j,0,N){
		acc [i + 1] [j + 1] = A [i] [j];
		acc [i + 1] [j + 1] += acc [i + 1] [j] + acc [i] [j + 1] - acc [i] [j];
	}

	ll ans = -INF;
	FOR(i,0,N) FOR(j,0,N) FOR(k,i + 1,N + 1) FOR(l,j + 1,N + 1){
		chmax(ans,acc [k] [l] - acc [i] [l] - acc [k] [j] + acc [i] [j]);
	}
	printf("%lld\n",ans);

	return 0;
}