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