#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int n;
int s[111][111];
int main(void){
  cin >> n;
  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= n; j++){
      cin >> s[i][j];
    }
  }
  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= n; j++){
      s[i][j] += s[i][j-1];
    }
  }
  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= n; j++){
      s[i][j] += s[i-1][j];
    }
  }

  int best = -(1<<30);
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      for(int k = i+1; k <= n; k++){
	for(int l = j+1; l <= n; l++){
	  best = max(best,s[k][l]-s[i][l]-s[k][j]+s[i][j]);
	}
      }
    }
  }
  cout << best << endl;
}