#include <cstdio>
#include <algorithm>
using namespace std;

int main(){
    int n;
    scanf("%d",&n);
    int arr[n*n];
    for(int row = 0; row < n; row++){
        for(int clm = 0; clm < n; clm ++){
            scanf("%d",&arr[row*n + clm]);
        }
    }
    int S[(n+1)*(n+1)];
    for(int i = 0; i < n+1; i++){
        S[i] = 0;
        S[i*(n+1)] = 0;
    }
    for(int row = 1; row < n+1; row++){
        for(int clm = 1; clm < n+1; clm ++){
            S[row*(n+1) + clm] = S[row*(n+1) + clm-1] + S[(row-1)*(n+1) + clm] - S[(row-1)*(n+1) + clm-1] + arr[(row-1)*n + clm-1];
        }
    }
    /*
    for(int i = 0; i < (n+1)*(n+1); i++){
        if(i % (n+1) == 0){
            printf("\n");
        }
        printf("%d ",S[i]);
    }
    printf("\n");
    */
    int maxs = S[n+2],maxe;
    for(int rowf = 1; rowf < n+1; rowf++){
        for(int clmf = 1; clmf < n+1; clmf++){
            for(int rowt = rowf; rowt < n+1; rowt++){
                for(int clmt = clmf; clmt < n+1; clmt++){
                    if(rowf == rowt && clmf == clmt){
                        maxe = S[rowt*(n+1) + clmt] - S[rowt*(n+1) + clmf-1] - S[(rowf-1)*(n+1) + clmt] + S[(rowf-1)*(n+1) + clmf-1];
                    }else{
                        maxe = max(maxe,S[rowt*(n+1) + clmt] - S[rowt*(n+1) + clmf-1] - S[(rowf-1)*(n+1) + clmt] + S[(rowf-1)*(n+1) + clmf-1]);
                    }
                    maxs = max(maxs,maxe);
                    //printf("maxe %d\n",maxe);
                    //printf("maxs %d\n",maxs);
                }
            }
        }
    }
    printf("%d",maxs);
}