#include <iostream>

int maxSubSum(int* B, int n)
{
	int* dp = new int[n];
	dp[0] = B[0];
	int res = B[0];
	for (int i=1; i<n; i++) {
		dp[i] = std::max(dp[i-1] + B[i], B[i]);
		res = std::max(res, dp[i]);
	}
	delete[] dp;
	return res;
}

int main()
{
	int n; std::cin >> n;
	int** A = new int*[n];
	for (int i=0; i<n; i++) A[i] = new int[n];
	
	for (int i=0; i<n; i++) {
		for (int j=0; j<n; j++) std::cin >> A[i][j];
	}
	
	int** vert_sum = new int*[n];
	for (int i=0; i<n; i++) vert_sum[i] = new int[n];
	for (int j=0; j<n; j++) {
		vert_sum[0][j] = A[0][j];
		for (int i=1; i<n; i++) vert_sum[i][j] = vert_sum[i-1][j] + A[i][j];
	}
	
	//int** hori_dp = new int*[n];
	//for (int i=0; i<n; i++) hori_dp[i] = new int[n];
	int* B = new int[n];
	int res = A[0][0];
	
	for (int i=0; i<n; i++) {
		for (int j=i; j<n; j++) {
			for (int k=0; k<n; k++) {
				if (i==0) B[k] = vert_sum[j][k];
				else B[k] = vert_sum[j][k] - vert_sum[i-1][k];
			}
			res = std::max(res, maxSubSum(B, n));
		}
	}
	
	std::cout << res << std::endl;				
	
	for (int i=0; i<n; i++) delete[] A[i];
	delete[] A;
	for (int i=0; i<n; i++) delete[] vert_sum[i];
	delete[] vert_sum;
	//for (int i=0; i<n; i++) delete[] hori_dp[i];
	//delete[] hori_dp;
	delete[] B;
	
	return 0;
}

