#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

int sum[100][100];
int main() {
	int n; cin >> n;
	rep(i, n)rep(j, n)scanf("%d", &sum[i][j]);
	for (int i = 1; i < n; i++)rep(j, n)sum[i][j] += sum[i - 1][j];
	rep(i, n)for (int j = 1; j < n; j++)sum[i][j] += sum[i][j - 1];
	int Max = INT_MIN;
	rep(i, n)rep(j, n)rep(k, i + 1)rep(t, j + 1) {
		int cnt = sum[i][j];
		if (t)cnt -= sum[i][t - 1];
		if (k)cnt -= sum[k - 1][j];
		if (k&&t)cnt += sum[k - 1][t - 1];
		Max = max(Max, cnt);
	}
	cout << Max << endl;
}