#include <cstdio>
#include <algorithm>

using namespace std;
typedef long long lint;

int main()
{
	int n;
	lint tbl[128][128];
	lint sum[128][128] = {0};
	
	scanf("%d", &n);
	
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			scanf("%lld", &tbl[i][j]);
	
	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			sum[i][j] += tbl[i][j];
			if (i) sum[i][j] += sum[i - 1][j];
			if (j) sum[i][j] += sum[i][j - 1];
			if (i && j) sum[i][j] -= sum[i - 1][j - 1];
		}
	}
	
	lint ma = -10000;
	
	for (int y1 = 0; y1 < n; y1++){
		for (int y2 = y1; y2 < n; y2++){
			lint trv = -10000;
			for (int x = 0; x < n; x++){
				lint v = sum[y2][x] - (x ? sum[y2][x - 1] : 0) - (y1 ? sum[y1 - 1][x] : 0) + (x && y1 ? sum[y1 - 1][x - 1] : 0);
				trv = max(trv + v, v);
				ma = max(ma, trv);
			}
		}
	}
	
	printf("%lld\n", ma);
	
	return (0);
}