#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int N, a[128][128];

int main(){
  scanf("%d", &N);
  rep(i, N) rep(j, N) scanf("%d", &a[i+1][j+1]);

  REP(i, 1, N+1) REP(j, 1, N+1) a[i][j] = a[i][j] - a[i-1][j-1] + a[i][j-1] + a[i-1][j];

  /*  rep(i, N+1){
    rep(j, N+1) printf("%d ", a[i][j]); puts("");
    }*/

  int res = -10000000;
  for(int x = 1; x <= N; x++){
    for(int y = 1; y <= N; y++){
      for(int i = 0; i < y; i++){
	for(int j = 0; j < x; j++){
	  res = max(res, a[y][x] - a[y][j] - a[i][x] + a[i][j]);
	}
      }
    }
  }

  printf("%d\n", res);
  return 0;
}