#include <cstdio>
#include <iostream>

using namespace std;

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

typedef long long int ll;

int main(){
    int n;
    cin >> n;
    int a[100][100] = {0};
    rep(i,n){
        rep(k,n){
            scanf("%d",&a[k][i]);
        }
    }

    ll sum[100][100] = {0};
    rep(i,n){
        sum[0][i] = a[0][i];
        reep(k,1,n){
            sum[k][i] += sum[k-1][i] + a[k][i];
        }
    }

    rep(i,n){
        reep(k,1,n){
            sum[i][k] += sum[i][k-1];
        }
    }

    /*rep(i,n){
        rep(k,n){
            printf("%3d",sum[k][i]);
        }
        puts("");
    }*/

    ll ans = -1<<18;
    rep(lx,n){
        rep(ty,n){
            reep(rx,lx,n){
                reep(uy,ty,n){
                    ll cou;
                    if(rx == lx)
                        cou = (sum[rx][uy]-sum[rx][ty]);
                    else
                        cou = (sum[rx][uy]-sum[rx][ty])-(sum[lx][uy]-sum[lx][ty]);
                    ans = max(cou,ans);
                }
            }
        }
    }
    cout << ans << endl;
}