#include<iostream>
#include<algorithm>
using namespace std;
int n, x[10000][10000], dp[10000][10000], maxn = -1000000000;
int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			cin >> x[i][j];
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			for (int k = 1; k <= i; k++) {
				for (int l = 1; l <= j; l++) {
					dp[i][j] += x[k][l];
				}
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			for (int k = i; k <= n; k++) {
				for (int l = j; l <= n; l++) {
					maxn = max(maxn, dp[i - 1][j - 1] + dp[k][l] - dp[i - 1][l] - dp[k][j - 1]);
				}
			}
		}
	}
	cout << maxn << endl;
}