#include<iostream>
using namespace std;

int A[100][100]={0};
int S[101][101]={0};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    
    Fill(A,0);
    Fill(S,0);
    int n;
    cin>>n;

    for(int i=0;i<n;++i){
        for(int j=0;j<n;++j){

            cin>>A[i][j];
        
        }
    }

    for(int i=0;i<n;++i){
        for(int j=0;j<n;++j){
    
            int sum=0;
    
            for(int k=0;k<=i;++k){
                for(int l=0;l<=j;++l){
    
                    sum+=A[k][l];
    
                }
            }
    
            S[i+1][j+1]=sum;
            //cout<<sum<<" "; //for debug
    
        }
    }

    int maxsum=A[0][0];

    for(int i=0;i<n;++i){
        for(int j=0;j<n;++j){
            for(int k=i+1;k<n+1;++k){
                for(int l=j+1;l<n+1;++l){
    
                    int partsum=S[k][l]-S[k][j]-S[i][l]+S[i][j];
                    maxsum=(partsum>maxsum?partsum:maxsum);
    
                }
            }
        }
    }

    cout<<maxsum<<"\n";

}