// 0098.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define roop(a,t) for(long long a=0;a<t;a++) 
//#define startfor(a,b,t) for(long long a=b;a<t;a++)
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	ll sum[105][105];
	ll ans = -9223372036854775;
	cin >> n;
	roop (i, n) {
		roop(j, n) {
			cin >> sum[i][j];
			if (j > 0) { sum[i][j] += sum[i][j - 1]; }
			ans = max(ans, sum[i][j]);
		}
	}
	for (ll j = 0; j < n; j++) {
		for (ll i = 0; i < n; i++) {			
			if (i > 0) 
			{ 
				sum[i][j] += sum[i - 1][j]; 
			}
			ans = max(ans, sum[i][j]);
		}
	}

	for (ll ix = -1; ix < n-1; ix++) {
		for (ll jx = ix + 1; jx < n; jx++) {
			for (ll iy = -1; iy < n - 1; iy++) {
				if (ix == iy&&ix == -1) { continue; }
				for (ll jy = iy + 1; jy < n; jy++) {
					ll jxjy = sum[jx][jy];
					ll jxiy = sum[jx][iy];
					ll ixjy = sum[ix][jy];
					ll ixiy = sum[ix][iy];
					if (ix == -1) { ixiy = 0; ixjy = 0; }
					if (iy == -1) { jxiy = 0; ixiy = 0; }

					ll s = jxjy - ixjy - jxiy + ixiy;
					ans = max(ans, s);
				}
			
			}
		}
	}

	
	cout << ans << endl;
	return 0;
}
