#include<iostream>
#include<vector>
#include<climits>

using namespace std;

int sumMat(vector<vector<int> > &table, int x, int y, int w, int h){
	int lt = x == 0 || y == 0 ? 0 : table[x-1][y-1];
	int lb = x == 0 ? 0 : table[x-1][y-1+h];
	int rt = y == 0 ? 0 : table[x-1+w][y-1];
	int rb = table[x-1+w][y-1+h];
	return rb - rt - lb + lt;
}

int main(void){
	int n;
	vector<vector<int> > mat;
	vector<vector<int> > table;

	cin >> n;
	for(int i=0;i<n;i++){
		vector<int> row;
		for(int j=0;j<n;j++){
			int inp;
			cin >> inp;
			row.push_back(inp);
		}
		mat.push_back(row);
	}

	table = mat;
	for(int i=0;i<n;i++){
		for(int j=0;j<n-1;j++){
			table[i][j+1] += table[i][j];
		}
	}
	for(int i=0;i<n-1;i++){
		for(int j=0;j<n;j++){
			table[i+1][j] += table[i][j];
		}
	}

	int maxSum = INT_MIN;
	for(int x=0;x<n;x++){
		for(int y=0;y<n;y++){
			for(int w=1;w+x<=n;w++){
				for(int h=1;h+y<=n;h++){
					maxSum = max(maxSum, sumMat(table, x, y, w, h));
				}
			}
		}
	}

	cout << maxSum << endl;

	return 0;
}