#include <bits/stdc++.h>

using namespace std;

int main ()
{
	int N;
	cin >> N;
	vector<vector<int>>data ( N + 1 , vector<int> ( N + 1 ) );
	for( size_t i = 1; i < N + 1; i++ )
	{
		for( size_t j = 1; j < N + 1; j++ )
		{
			cin >> data[i][j];
		}
	}
	for( size_t i = 1; i < N + 1; i++ )
	{
		for( size_t j = 1; j < N + 1; j++ )
		{
			data[i][j] += data[i][j - 1];
		}
	}
	for( size_t i = 1; i < N + 1; i++ )
	{
		for( size_t j = 1; j < N + 1; j++ )
		{
			data[i][j] += data[i - 1][j];
		}
	}
	long long int ans = INT_MIN;
	for( size_t i = 0; i < N; i++ )
	{
		for( size_t j = 0; j < N; j++ )
		{
			for( size_t k = 1; k < N + 1; k++ )
			{
				for( size_t l = 1; l < N + 1; l++ )
				{
					long long int num = data[k][l] + data[i][j] - data[k][j] - data[i][l];
					if( num > ans )
					{
						ans = num;
					}
				}
			}
		}
	}
	cout << ans << endl;
}