//
//  main.cpp
//  Maximum Sum Sequence II
//
//  Created by 八代 光平 on 13/04/24.
//  Copyright (c) 2013年 八代 光平. All rights reserved.
//

#include <iostream>
#include<stdlib.h>
#include<stdio.h>

int main(int argc, const char * argv[])
{
    int n=0;
    scanf("%d", &n);
    int a[n][n];
    
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            scanf("%d" ,&a[i][j]);
        }
    }
    
//        1,3,-9,2,
//        2,7,-1,5,
//        -8,3,2,-1,
//        5,0,-3,1
//    };
//        1, 3, 4, 7, -2, 1,
//        3, 2, 4, -5, -9, 8,
//        -1 ,-4, -5, 2, 6, 7,
//        3, 3, -2, 4, 5, -9,
//        1, -3, 4, -7, -2, 1,
//        3, 2, -4, 5, -9, -8,
//    };
    
//    for(int i=0; i<n; i++){
//        for(int j=0; j<n; j++){
//            printf( "%3d",a[i][j]);
//        }
//        std::cout << "\n";
//    }
    
    int left = 0;
    int right= n-1;
    
    int top  = 0;
    int under= n-1;
    
    int check=1;
    
    while(check==1){
        int lsum=0;
        int rsum=0;
        int tsum=0;
        int usum=0;
        
        for(int i=left; i<=right; i++){
            tsum+=a[top][i];
            usum+=a[under][i];
        }
        for(int i=top; i<=under; i++){
            lsum+=a[i][left];
            rsum+=a[i][right];
        }
        
        if(tsum<0){
            top++;
        }else if(usum<0){
            under--;
        }else if(lsum<0){
            left++;
        }else if(rsum<0){
            right--;
        }else if((tsum+lsum-a[top][left])<0){
            top++;
            left++;
        }else if((tsum+rsum-a[top][right])<0){
            top++;
            right--;
        }else if((usum+lsum-a[under][left])<0){
            under--;
            left++;
        }else if((usum+rsum-a[under][right])<0){
            under--;
            right--;
        /*-----------------*/
        }else if((tsum+lsum+rsum-a[top][left]-a[top][right])<0){
            top++;
            left++;
            right--;
        }else if((tsum+rsum+usum-a[top][right]-a[under][right])<0){
            top++;
            under--;
            right--;
        }else if((usum+lsum+rsum-a[under][left]-a[under][right])<0){
            under--;
            left++;
            right--;
        }else if((tsum+usum+lsum-a[under][left]-a[top][left])<0){
            top++;
            under--;
            left++;
        }else if((tsum+usum+lsum+rsum-a[under][left]-a[top][left]-a[under][right]-a[top][right])<0){
            top++;
            under--;
            right--;
            left++;
        }else{
            check =0;
        }
//        printf("left::%d\n",left);
//        printf("right::%d\n",right);
//        printf("top::%d\n",top);
//        printf("under::%d\n",under);
//        printf("\n");
    }

    
    
    
 
    int temp =0;
        
        
    //std::cout << "\n";
    for(int i=top; i<=under; i++){
        for(int j=left; j<=right; j++){
            //printf( "%3d",a[i][j]);
            temp += a[i][j];
        }
        //std::cout << "\n";
    }
    printf( "%3d",temp);
    
    
}