#include<bits/stdc++.h>
using namespace std;
const int inf = 1001001001;
int main(){
    int n,i,j,k,l,ans = -inf;scanf("%d",&n);
    int rp[n+1][n+1];
    for(i=0;i<=n;i++) rp[0][i] = rp[i][0] = 0;
    for(i=1;i<=n;i++){
        for(j=1;j<=n;j++) scanf("%d",&rp[i][j]);
    }
    for(i=1;i<=n;i++){
        for(j=2;j<=n;j++) rp[i][j] += rp[i][j-1];
    }
    for(i=1;i<=n;i++){
        for(j=2;j<=n;j++) rp[j][i] += rp[j-1][i];
    }
    for(i=1;i<=n;i++){
        for(j=i;j<=n;j++){
            for(k=1;k<=n;k++){
                for(l=k;l<=n;l++) ans = max(ans,rp[j][l]-rp[j][k-1]-rp[i-1][l]+rp[i-1][k-1]);
            }
        }
    }
    printf("%d\n",ans);
}
