#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

int ruisekiwa[101][101];
int main()
{
	int a; cin >> a;
	for (int b = 0; b < a; b++) {
		for (int c = 0; c < a; c++) {
			int d; scanf("%d", &d);
			ruisekiwa[b + 1][c + 1] = ruisekiwa[b + 1][c] + ruisekiwa[b][c + 1] - ruisekiwa[b][c] + d;
		}
	}
	int MAX = 0;
	for (int e = 0; e < a; e++) {
		for (int f = e + 1; f <= a; f++) {
			for (int g = 0; g < a; g++) {
				for (int h = g + 1; h <= a; h++) {
					MAX = max(MAX, ruisekiwa[f][h] - ruisekiwa[e][h] - ruisekiwa[f][g] + ruisekiwa[e][g]);
				}
			}
		}
	}
	cout << MAX << endl;
}