#include <iostream>

using namespace std;
typedef long long int lint;

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

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

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

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

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

					sum = s[i2][j2] - ((i1 != 0) ? s[i1 - 1][j2] : 0) - ((j1 != 0) ? s[i2][j1 - 1] : 0) + ((i1 != 0 && j1 != 0)? s[i1 - 1][j1 - 1] : 0);
					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;
}