#include<bits/stdc++.h>
#define loop(vals,times) for(vals=0;vals<times;vals++)
using namespace std;


int main()
{
    int n,i,j,I,J;
    long long max=-100000000000000;
    cin>>n;
    int a[n][n];
    int s[n][n];

    loop(j,n){
    loop(i,n){
    cin>>a[j][i];
    }
    }
    
    loop(j,n)s[j][0]=a[j][0];
    
    loop(i,n)s[0][i]=a[0][i];
    
    loop(j,n){
    loop(i,n-1)s[j][i+1]=s[j][i]+a[j][i+1];
    }
    
    loop(i,n){
    loop(j,n-1){s[j+1][i]=s[j][i]+s[j+1][i];
    }
    }
    
    loop(i,n){
    loop(j,n){
       
    loop(I,n){
    loop(J,n){
    if(i!=0&&j!=0){
    if(max<=s[J][I]-s[J][i-1]-s[j-1][I]-s[j-1][i-1])max=s[J][I]-s[J][i-1]-s[j-1][I]-s[j-1][i-1];
    }else if(i==0&&j!=0){if(max<=s[J][I]-s[j-1][I])max=s[J][I]-s[j-1][I];
    }else if(j==0&&i!=0){if(max<=s[J][I]-s[J][i-1])max=s[J][I]-s[J][i-1];
    }else if(i==0&&j==0){if(max<=s[J][I])max=s[J][I];}
    cout<<max<<endl;    
    }
    }
        
    }
    }
    cout<<max<<endl;
}

