#include <cstdio>
#include <algorithm>
using namespace std;

#define INF 0x7fffffff

int n;
int field[101][101];
int imos[101][101];

int main() { 
  scanf("%d", &n);
  for (int i=1; i<=n; i++) {
    for (int j=1; j<=n; j++) {
      scanf("%d", &field[i][j]);
    }
  }

  for (int i=1; i<=n; i++) {
    for (int j=1; j<=n; j++) {
      imos[i][j] += imos[i][j-1] + field[i][j];
    }
  }

  for (int i=1; i<=n; i++) {
    for (int j=1; j<=n; j++) {
      imos[i][j] += imos[i-1][j];
    }
  }

  int ans = -INF;
  for (int i=1; i<=n; i++) {
    for (int j=i; j<=n; j++) {
      for (int k=1; k<=n; k++) {
        for (int l=k; l<=n; l++) {
          ans = max(ans, imos[j][l] - imos[i-1][l] - imos[j][k-1] + imos[i-1][k-1]);
        }
      }
    }
  }

  printf("%d\n", ans);
}