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

using namespace std;
typedef long long ll;


#define SIZE 101
#define INF 1000000000
#define LLINF 1000000000000000000LL


int main(){
  int n, a[SIZE][SIZE];
  int sum[SIZE][SIZE] = {};

  scanf("%d",&n);

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      scanf("%d",a[i]+j);
      sum[i+1][j+1] = a[i][j] + sum[i+1][j];
    }
  }

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

  int ans = -INF;
  
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){

      for(int p=i+1;p<n+1;p++){
        for(int q=j+1;q<n+1;q++){
          ans = max(ans, sum[i][j] + sum[p][q] - sum[i][q] - sum[p][j]);
        }
      }
      
    }
  }

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

