#include<iostream>

using namespace std;

#define rep(i, n) for (int i = 0; i < int(n); ++i)

int main() {
  int n;
  cin >> n;
  int m[n][n];
  long long s[n + 1][n + 1];
  rep (i, n) rep (j, n) cin >> m[i][j];
  rep (i, n + 1) rep (j, n + 1) s[i][j] = 0;
  rep (i, n) rep (j, n) s[i + 1][j + 1] = m[i][j] + s[i][j + 1] + s[i + 1][j] - s[i][j];
  long long res = -1e15;
  rep (i, n) rep (j, n) rep (ii, i + 1) rep (jj, j + 1) {
    res = max(res, s[i + 1][j + 1] - s[i + 1][jj] - s[ii][j + 1] + s[ii][jj]);
  }
  cout << res << endl;
  return 0;
}