#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
#include <iostream>
using namespace std;



int main()
{
	int n;
	int d[100][100];
	cin >> n;
	for(int i = 0; i< n; i++)
		for (int j = 0; j < n; j++)
			cin >> d[i][j];

	int sl = -100000;
	for (int p = 0; p < n; p++)
	{
		for (int q = 0; q <= p; q++)
		{
			vector<int> a = vector<int>(100, 0);
			for (int r = q; r <= p; r++)
			{
				for (int t = 0; t < n; t++)
				{
					a[t] += d[r][t];
				}
			}


			vector<int> s = vector<int>(1, 0);
			bool f = true;
			bool plus = false;
			for (int i = 0; i < n; i++)
			{
				if (a[i] >= 0)
				{
					if (!f)
						f = true;
					if (!plus)
						plus = true;
					s[0] += a[i];
				}
				else if (s[0] > abs(a[i]))
				{
					if (f)
					{
						s.push_back(s[0]);
						f = false;
					}
					s[0] += a[i];
				}
				else
				{
					s[0] = 0;
				}

			}
			if (!plus)
			{
				int max = a[0];
				for (int i = 1; i < n; i++)
				{
					if (max < a[i])
						max = a[i];
				}
				if (sl < max)
					sl = max;
				continue;
			}
			for (int i = 1; i < s.size(); i++)
			{
				if (s[i] > s[0])
					s[0] = s[i];
			}
			if (sl < s[0])
				sl = s[0];
		}
	}
	cout << sl << endl;

	return 0;
}