#include <iostream>

using namespace std;
typedef long long int lint;

void answer()
{
	int n;
	cin >> n;

	int** a = new int*[n + 1];
	int** s = new int*[n + 1];
	for (int i = 0; i <= n; i++) {
		a[i] = new int[n + 1];
		s[i] = new int[n + 1];
	}

	int sum;
	for (int i = 0; i <= n; i++)
		for (int j = 0; j <= n; j++)
			a[i][j] = s[i][j] = 0;

	for (int i = 1; i <= n; i++) {
		sum = 0;
		for (int j = 1; j <= n; j++) {
			cin >> a[i][j];
			sum += a[i][j];
			s[i][j] = s[i - 1][j] + sum;
		}
	}

	int max = 0;
	for (int i1 = 1; i1 <= n; i1++) {
		for (int j1 = 1; j1 <= n; j1++) {

			for (int i2 = i1; i2 <= n; i2++) {
				for (int j2 = j1; j2 <= n; j2++) {

					sum = s[i2][j2] - s[i1 - 1][j2] - s[i2][j1 - 1] + s[i1 - 1][j1 - 1];
					if (max < sum) max = sum;
				}
			}

		}
	}

	cout << max << endl;

	for (int i = 0; i <= n; i++) {
		delete[] a[i];
	}
	delete[] a;
}

int main()
{
	answer();
	return 0;
}