#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdlib>

using namespace std;

#define ALL(c) c.begin(),c.end()
#define RALL(c) c.rbegin(),c.rend()
#define REP(i,x,y) for(int i=(x);i<(y);++i)
#define MP(a,b) make_pair((a),(b))
#define F_ first
#define S_ second

typedef long long int lli;
typedef pair<int,int> Pi;

const int INF=100000000;
const long long int INF_=1000000000000000000;

int main(){
	int N;
	cin >> N;
	long long int ans=0;
	vector<vector<int> > A(N,vector<int>(N));
	REP(y,0,N){
		REP(x,0,N){
			cin >> A[y][x];
		}
	}
	vector<vector<int> > s(N,vector<int>(N));
	REP(y,0,N) s[y][0]=A[y][0];
	REP(y,0,N){
		REP(x,1,N){
			s[y][x]=s[y][x-1]+A[y][x];
		}
	}
	vector<vector<int> > s_(N,vector<int>(N));
	REP(x,0,N) s_[0][x]=s[0][x];
	REP(x,0,N){
		REP(y,1,N){
			s_[y][x]=s_[y-1][x]+s[y][x];
		}
	}
	REP(sy,0,N){
		REP(sx,0,N){
			REP(ey,sy+1,N){
				REP(ex,sx+1,N){
					lli tmp=0;
					tmp+=s_[ey][ex];
					if(sy!=0) tmp-=s_[sy-1][ex];
					if(sx!=0) tmp-=s_[ey][sx-1];
					if(sy!=0&&sx!=0) tmp+=s_[sy-1][sx-1];
					ans=max(ans,tmp);
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}