#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  int n; cin >> n;
  vector<vector<int>> a(n, vector<int>(n));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) cin >> a[i][j];
  }
  vector<vector<ll>> s(n + 1, vector<ll>(n + 1, 0));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) s[i + 1][j + 1] = s[i + 1][j] + a[i][j];
  }
  for (int j = 0; j < n; ++j) {
    for (int i = 0; i < n; ++i) s[i + 1][j + 1] += s[i][j + 1];
  }
  ll mx = -10000;
  for (int sx = 1; sx <= n; ++sx) {
    for (int sy = 1; sy <= n; ++sy) {
      for (int tx = sx; tx <= n; ++tx) {
        for (int ty = sy; ty <= n; ++ty) {
          ll sum = s[tx][ty] - s[sx - 1][ty] - s[tx][sy - 1] + s[sx - 1][sy - 1];
          mx = max(mx, sum);
        }
      }
    }
  }
  cout << mx << endl;
  return 0;
}

