#include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
  int n,a[110][110],rs[110][110],sum[110][110];
  cin >> n;
  rep(i,n)rep(j,n)cin >> a[i][j];

  rep(i,n)rs[0][i] = 0;
  rep(i,n){
    rs[i+1][0] = 0;
    rep(j,n){
      rs[i+1][j+1] = rs[i+1][j] + a[i][j];
    }
  }

  rep(i,n+1){
    sum[0][i] = 0;
    rep(j,n){
      sum[j+1][i] = sum[j][i] + rs[j+1][i];
    }
  }

  int ans = -1000000000;
  rep(i,n)rep(j,n)rep(k,n+1)rep(l,n+1){
    if(i<k && j<l){
      ans = std::max(ans,sum[k][l]-sum[k][j]-sum[i][l]+sum[i][j]);
    }
  }
  cout << ans << endl;
}