#include<iostream>
using namespace std;

int main(void)
{
	int n;
	int a[100][100];
	int S[100][100];
	int S2[101][101]; //S[100][100]???????????????S2[i][j]=S[i-1][j-1](i*j!=0),S2[i][j]=0(i*j==0)
	int T[100][100]; //T[i][j]???a[i][0]??????a[i][j]?????§??????
	cin>>n;
 
	//??\???
	for(int i=0;i<n;++i){
		int tmp=0;
		for(int j=0;j<n;++j){
			cin>>a[i][j];
			tmp+=a[i][j];
			T[i][j]=tmp;
		}
	}

	/*
	for(int i=0;i<n;++i){
		for(int j=0;j<n;++j){
			cout<<T[i][j]<<" ";
		}
		cout<<endl;
	}*/

	//S[i][j]????¨????
	for(int j=0;j<n;++j){
		int tmp=0;
		for(int i=0;i<n;++i){
			tmp+=T[i][j];
			S[i][j]=tmp;
		}
	}

	/* checked
	for(int i=0;i<n;++i){
		for(int j=0;j<n;++j){
			cout<<S[i][j]<<" ";
		}
		cout<<endl;
	}*/

	//S[i][j]??????S2[i][j]?????????
	for(int i=0;i<n+1;++i){
		for(int j=0;j<n+1;++j){
			if(i==0||j==0){
				S2[i][j]=0;
			} else {
				S2[i][j]=S[i-1][j-1];
			}
		}
	}

	/* checked
	for(int i=0;i<n+1;++i){
		for(int j=0;j<n+1;++j){
			cout<<S2[i][j]<<" ";
		}
		cout<<endl;
	}*/

	long max=S2[1][1];

	for(int i=1;i<n+1;++i){
		for(int j=1;j<n+1;++j){
			for(int k=0;k<i;++k){
				for(int l=0;l<j;++l){
					long square=S2[i][j]-S2[i][l]-S2[k][j]+S2[k][l]; //??????????????????????????¢?????¢???
					if(square>max) max=square;
				}
			}
		}
	}

	cout<<max<<endl;

	return 0;
}