#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
 
const int INF = 10000000;
const int mod = 1e9 + 7;
const double EPS = 1e-9;
 

int main(){
	int n;
	cin>>n;
	vll v(n, vl(n, 0LL));

	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			cin>>v[i][j];
		}
	}

	vll s(n + 1, vl(n + 1, 0LL));
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			if(j == 1) s[i][j] = v[i-1][j-1];
			else s[i][j] = s[i][j-1] + v[i-1][j-1];
		}
	}

	for(int i = 2; i <= n; i++){
		for(int j = 1; j <= n; j++){
			s[i][j] = s[i][j] + s[i-1][j];
		}
	}

	ll ans = s[1][1];
	for(int y1 = 1; y1 <= n; y1++){
		for(int x1 = 1; x1 <= n; x1++){
			for(int y2 = 0; y2 < y1; y2++){
				for(int x2 = 0; x2 < x1; x2++){
					ans = max(ans,s[y1][x1]-s[y1][x2]-s[y2][x1]+s[y2][x2]);
				}
			}
		}
	}

	cout<<ans<<endl;
}