#include <iostream>
#include <vector>
#include <climits>

int main() {
	int n;
	std::cin >> n;
	std::vector<std::vector<int>> mat(n + 1, std::vector<int>(n + 1, 0));
	for (auto i = 1; i <= n; ++i) {
		for (auto j = 1; j <= n; ++j) {
			std::cin >> mat[i][j];
			mat[i][j] += mat[i][j - 1] + mat[i - 1][j] - mat[i - 1][j - 1];
		}
	}
	int max = INT_MIN;
	for (auto left = 0; left < n; ++left) {
		for (auto right = left + 1; right <= n; ++right) {
			for (auto top = 0; top < n; ++top) {
				for (auto bottom = top + 1; bottom <= n; ++bottom) {
					if (max < mat[right][bottom] - mat[right][top] - mat[left][bottom] + mat[left][top])
						max = mat[right][bottom] - mat[right][top] - mat[left][bottom] + mat[left][top];
				}
			}
		}
	}
	std::cout << max << std::endl;

}
