#include <iostream>
using namespace std;

int main() {
 int n;
 int a[110][110];
 int S[110][110];
 int s[110];
 cin >> n;
 for (int i=0; i<n; ++i) {
  for (int j=0; j<n; ++j) {
   cin >> a[i][j];
  }
 }
 for (int i=0; i<=n; ++i) {
  S[i][0] = 0;
  s[0] = 0;
  for (int j=0; j<n; ++j) {
   s[j+1] = s[j] + a[i-1][j];
   if (i == 0) { S[i][j+1] = 0; }
   else { S[i][j+1] = S[i-1][j+1] + s[j+1]; }
  }
 }
 int max = -10001;
 for (int i=0; i<n; ++i) {
  for (int j=i+1; j<=n; ++j) {
   for (int k=0; k<n; ++k) {
    for (int l=k+1; l<=n; ++l) {
     int t = S[j][l] - S[i][l] - S[j][k] + S[i][k];
     max = (t > max) ? t : max;
    }
   }
  }
 }
 cout << max << endl;
}
