#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <ctype.h>
#include <string>
#include <iostream>
#include <vector>
#include <stack>
#include <fstream>
#include <sstream>
#include <queue>
#include <exception>
#include <cmath>
#include <numeric>

using namespace std;
typedef long long int lint;

#define SIZE 100

int mat[SIZE + 1][SIZE + 1] = { 0 };
int sum[SIZE + 1] = { 0 };

void print(int n) {
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			printf("%4d", mat[i][j]);
		}
		cout << endl;
	}
}

//Kadane's algorithm
int max_subarray(int n) {
	int max_ending_here, max_so_far;
	max_ending_here = max_so_far = sum[1];
	for (int i = 2; i <= n; i++) {
		max_ending_here = max(sum[i], max_ending_here + sum[i]);
		max_so_far = max(max_so_far, max_ending_here);
	}
	return max_so_far;
}

void AOJ0098() {
	int n;
	cin >> n;

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

	//print(n);

	//?????????????´???????????¨????
	for (int j = 1; j <= n; j++) {
		for (int i = 1; i <= n; i++) {
			mat[i][j] += mat[i - 1][j];
		}
	}

	//print(n);

	//i1 ?????¨ i2 ????????????????????????
	//	1	3	-9	2
	//	3	10	-10	7	i1
	//	-------------
	//	-5	13	-8	6
	//	0	13	-11	7	i2
	//	-------------

	int max_sub_matrix = -1e9;
	for (int i1 = 0; i1 < n; i1++) {
		for (int i2 = i1 + 1; i2 <= n; i2++) {
			for (int j = 1; j <= n; j++) {
				sum[j] = mat[i2][j] - mat[i1][j];
			}
			//maximum sum sequence ?????????
			int max_sum_sequence = max_subarray(n);
			if (max_sub_matrix < max_sum_sequence) max_sub_matrix = max_sum_sequence;
		}
	}
	cout << max_sub_matrix << endl;
	return;
}

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