#include <iostream>
#include <vector>

using namespace std;

void solve()
{
	int n;
	cin >> n;
	vector< vector<int> > a(n + 1, vector<int>(n + 1));
	for(int i = 1; i <= n; ++i)
	{
		for(int j = 1; j <= n; ++j)
		{
			cin >> a[i][j];
		}
	}
	for(int i = 1; i <= n; ++i)
	{
		for(int j = 1; j <= n; ++j)
		{
			a[i][j] += a[i][j - 1];
		}
	}

	for(int i = 1; i <= n; ++i)
	{
		for(int j = 1; j <= n; ++j)
		{
			a[j][i] += a[j - 1][i];
		}
	}
	
	int max_val = -100000000;
	for(int i = 0; i < n; ++i)
	{
		for(int j = 0; j < n; ++j)
		{
			for(int k = i + 1; k <= n; ++k)
			{
				for(int l = j + 1; l <= n; ++l)
				{
					max_val = max(max_val, a[i][j] - a[i][l] - a[k][j] + a[k][l]);
				}
			}
		}
	}
	cout << max_val << endl;
}

int main()
{
	solve();
	return(0);
}