#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N=in();
	vector<vector<int>> A(N,vector<int>(N)),S(N+1,vector<int>(N+1,0));
	REP(i,N){
		REP(j,N){
			A[i][j] = in();
			S[i+1][j+1] = A[i][j];
		}
	}
	REP(i,N){
		for(int j=1;j<N;j++){
			S[i+1][j+1] = A[i][j]+S[i+1][j];
		}
	}
	for(int i=1;i<N+1;i++){
		REP(j,N+1){
			S[i][j] += S[i-1][j];
		}
	}

	int MV=-(1<<30);
	for(int i=0;i<N+1;i++){
		for(int v=i+1;v<N+1;v++){
			for(int j=0;j<N+1;j++){
				for(int u=j+1;u<N+1;u++){
					int sum = S[i][j]+S[v][u]-S[i][u]-S[v][j];
					MV = max(MV,sum);
				}
			}
		}
	}

	out(MV);
	return 0;
}
