#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
	int n;
	int ary[101][101] = {};
	int max_ = -999999999;

	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			cin >> ary[i][j];
		}
	}

	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			ary[i][j] += ary[i][j - 1];
		}
	}

	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			ary[i][j] += ary[i - 1][j];
		}
	}

	for (int a = 0; a < n; a++)
	{
		for (int b = 0; b < n; b++)
		{
			for (int c = a + 1; c <= n; c++)
			{
				for (int d = b + 1; d <= n; d++)
				{
					int t = ary[c][d] + ary[a][b] - ary[c][b] - ary[a][d];
					max_ = max(max_, t);
				}
			}
		}
	}
	cout << max_ << endl;

	return 0;
}