#include <iostream>
#include <cstring>
#include <algorithm>
#include <limits.h>

using namespace std;

int GetMaxOfSequence(int *pArr, int n) {
	int i,tmp, maxSum;

	maxSum = INT_MIN;
	tmp = 0;
	for (i = 0; i < n; i++) {
		if (tmp > 0) {
			tmp += pArr[i];
		}
		else {
			tmp = pArr[i];
		}
		maxSum = max(maxSum, tmp);
	}
	return maxSum;
}


int main(void) {
	int n,i, j,k, maxValue;
	int arr[101][101],tmp[101];

	while (cin >> n) {
		memset(arr, 0, sizeof(arr));
		for (i = 0; i < n; i++) {
			for (j = 0; j < n; j++) {
				cin >> arr[i][j];
			}
		}

		maxValue = INT_MIN;
		for (i = 0; i < n; i++) {
			memset(tmp, 0, sizeof(tmp));
			for (j = i; j < n; j++) {
				for (k = 0; k < n; k++) {
					tmp[k] += arr[j][k];
				}

				maxValue = max(maxValue, GetMaxOfSequence(tmp, n));
			}
		}

		cout << maxValue << endl;
	}

	return 0;
}


