#include <bits/stdc++.h>
  
using namespace std;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)
  
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
  
#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

#define INF 1000000000

typedef long double Real;
#define EPS 1e-13
#define EQ(x) (-EPS<x && x<EPS)
typedef complex<Real> P;
Real dot(P a,P b){return real(conj(a)*b);}
Real cross(P a,P b){return imag(conj(a)*b);}

ll a[101][101];
ll sm[101][101];

inline ll getsm(int t,int b,int l,int r){
  return sm[b][r]-(t>0?sm[t-1][r]:0)-(l>0?sm[b][l-1]:0)+(t>0&&l>0?sm[t-1][l-1]:0);
}

int main(){
  int n;
  cin>>n;
  REP(i,n)REP(j,n)cin>>a[i][j];
  REP(i,n)REP(j,n)sm[i][j]=a[i][j];
  REPR(i,n)REP(j,n)sm[i][j]+=sm[i-1][j];
  REP(i,n)REPR(j,n)sm[i][j]+=sm[i][j-1];
  ll mx = -1145141919;
  REP(top,n)FOR(bot,top,n){
    int left = 0, right = 0;
    while(left<n && right<n){
      ll t = getsm(top,bot,left,right);
      mx = max(mx,t);
      if(t>0){
        ++right;
      }else{
        right = left = right+1;
      }
    }
  }
  cout<<mx<<endl;
  return 0;
}