#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;


int n;
int a[101][101];
int table[101][101];

int main(){
	cin >> n;
	REP(i, n){
		REP(j, n){
			cin >> a[i][j];
			if (i == 0)table[i][j] = a[i][j];
			else{
				table[i][j] = a[i][j] + table[i - 1][j];
			}
		}
	}
	REP(i, n){
		for (int j = 1; j < n; j++){
			table[i][j] += table[i][j - 1];
		}
	}
	//REP(i, n){
	//	REP(j, n){
	//		cout << table[i][j] << " ";
	//	}
	//	cout << endl;
	//}
	int ans = -10000000;
	REP(i, n){
		REP(j, n){
			REP(k, i + 1){
				REP(l, j + 1){
					int num = table[i][j];
					if (k != 0)num -= table[k - 1][j];
					if (l != 0)num -= table[i][l - 1];
					if (k != 0 && l != 0)num += table[k - 1][l - 1];
					ans = max(ans, num);
				}
			}
		}
	}
	cout << ans << endl;
}