#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n;
  cin >> n;

  int a[110][110] = {};
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      cin >> a[i][j];
    }
  }
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      a[i][j + 1] += a[i][j];
    }
  }
  for (int j = 0; j <= n; j++) {
    for (int i = 0; i <= n; i++) {
      a[i + 1][j] += a[i][j];
    }
  }
  int ans = INT_MIN;
  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++) {
          ans = max(ans, a[i][j] + a[k][l] - a[i][l] - a[k][j]);
        }
      }
    }
  }
  cout << ans << endl;

  return 0;
}
