#include <iostream>
#include <algorithm>

using namespace std;

const int N = 100;
const int INF = 100000000;


int n, data[N][N], yoko[N][N], tate[N];


int main(){
  cin >> n;
  for(int i=0;i<n;i++) for(int j=0;j<n;j++) cin >> data[i][j];
  for(int i=0;i<n;i++){
    yoko[i][0] = data[i][0];
    for(int j=1;j<n;j++) yoko[i][j] = yoko[i][j-1] + data[i][j];
  }
  /*for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      cout << yoko[i][j] << ' ';
    }
    cout << endl;
    }*/
  int ans = -INF;
  for(int i=0;i<n;i++) for(int j=0;j<n;j++) ans = max(ans, data[i][j]);
  for(int i=0;i<n;i++){
    for(int j=i;j<n;j++){
      if(i == 0) for(int k=0;k<n;k++) tate[k] = yoko[k][j];
      else for(int k=0;k<n;k++) tate[k] = yoko[k][j] - yoko[k][i-1];
      int tmp[N];
      tmp[0] = tate[0];
      for(int k=1;k<n;k++) tmp[k] = tmp[k-1] + tate[k];
      int valm = 0, valM = -INF;
      for(int k=0;k<n;k++){
        valM = max(valM, tmp[k]);
        if(valm > tmp[k]){
          valm = tmp[k];
          valM = tmp[k];
        }
        //cout << valm << ' ' << valM << endl;
        if(valm != valM) 
          ans = max(ans, valM - valm);
      }
      /*cout << "(" << i << ", " << j << ")" << endl;
      for(int k=0;k<n;k++) cout << tate[k] << ' '; cout << endl;
      cout << "ans = " << ans << endl;*/
    }
  }
  cout << ans << endl;
}