#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <stack>
#include <numeric>
#include <ctime>
#include <algorithm>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <map>

using namespace std;
typedef long long int lint;

int matsum(int a, int b, int c, int d, int** Mat)
{
	int ret = Mat[c][d];
	if (a > 0) ret -= Mat[a - 1][d];
	if (b > 0) ret -= Mat[c][b - 1];
	if (a > 0 && b > 0) ret += Mat[a - 1][b - 1];
	return ret;
}

int maxsum(int i, int j, int n, int** Mat)
{
	int ret = -10000000;
	int buf;
	int k = 0;
	int l = 0;
	while (l < n){
		while ((buf = matsum(i, k, j, l, Mat)) >= 0){
			if (ret < buf) ret = buf;
			l++;
			if (l == n) return ret;
		}
		k = l = l + 1;
	}
	return ret;
}

int main()
{
	//clock_t start = clock();

	int n;
	cin >> n;
	int** Mat = new int*[n];
	int** Sum = new int*[n];
	for (int i = 0; i < n; i++) {
		Mat[i] = new int[n];
		Sum[i] = new int[n];
	}

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

	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			if (j == 0) continue;
			else Mat[i][j] += Mat[i][j - 1];
		}
	}

	for (int j = 0; j < n; j++){
		for (int i = 0; i < n; i++){
			if (i == 0) continue;
			else Mat[i][j] += Mat[i - 1][j];
		}
	}

	int max = -10000000;
	int buf;
	for (int i = 0; i < n; i++){
		for (int j = i; j < n; j++){
			//i行からj行までに着目した尺取り法
			buf = maxsum(i, j, n, Mat);
			if (max < buf) max = buf;
		}
	}
	cout << max << endl;

	//clock_t end = clock();
	//std::cout << (double)(end - start) / CLOCKS_PER_SEC << "sec.\n";

	return 0;
}