#include <iostream>
#include <vector>
using namespace std;

const int N_INF = (1 << 31);

int main(){
	int n, max = N_INF, sum;
	vector< vector< int > > mat;
	vector< vector< int > > table;
	
	cin >> n;
	
	mat.resize(n);
	for(int i = 0; i < n; ++i){
		mat[i].resize(n);
		for(int j = 0; j < n; ++j){
			cin >> mat[i][j];
		}
	}
	
	table.resize(n + 1);
	for(int i = 0; i <= n; ++i){
		table[i].resize(n + 1);
		
		if(i >= 1){
			table[i][1] = mat[i - 1][0];
			
			for(int j = 1; j <= n; ++j){
				table[i][j] = table[i][j - 1] + mat[i - 1][j - 1];
			}
		}
	}
	
	for(int j = 1; j <= n; ++j){
		for(int i = 1; i <= n; ++i){
			table[i][j] += table[i - 1][j];
		}
	}
	
	for(int i = 1; i <= n; ++i){
		for(int j = 1; j <= n; ++j){
			for(int k = i; k <= n; ++k){
				for(int l = j; l <= n; ++l){
					
					sum = table[k][l] - table[i - 1][l] - table[k][j - 1] + table[i - 1][j - 1];
					
					if(sum > max) max = sum;
				}
			}
		}
	}
	cout << max << endl;
	
	return 0;
}