#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//????????????????????????????????????
#define int long long
#define str string
typedef long long ll;
typedef long double ld;
const ll inf = 999999999999999999;
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {
	ll to, cost;
};
ll gcm(ll i, ll j) {//?????§??¬?´???°
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
//---------------------------------------------------
//+++++++++++++++++++++++++++++++++++++++++++++++++++
int n, a[100][100], b[100][100], ans = -1 * inf;
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> a[i][j];
			if (i == 0) {
				if (j == 0)
					b[i][j] = a[i][j];
				else
					b[i][j] = b[i][j - 1] + a[i][j];
			}
			else if (j == 0) {
				b[i][j] = b[i - 1][j] + a[i][j];
			}
			ans = max(ans, a[i][j]);
		}
	}
	for (int i = 1; i < n; i++) {
		for (int j = 1; j < n; j++) {
			b[i][j] = a[i][j] + b[i - 1][j] + b[i][j - 1] - b[i - 1][j - 1];
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			for (int x = 0; x <= i; x++) {
				for (int y = 0; y <= j; y++) {
					int sum = b[i][j];
					if (x > 0)
						sum -= b[x - 1][j];
					if (y > 0)
						sum -= b[i][y - 1];
					if (x > 0 && y > 0)
						sum += b[x - 1][y - 1];
					ans = max(ans, sum);
				}
			}
		}
	}
	cout << ans << endl;
	getchar(); getchar();
}