#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <sstream>
 
#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

int main(int argc, char **argv){
	int n;
	std::vector<std::vector<int> > A;
	std::vector<std::vector<int> > S;
	std::vector<int> dp;
	int result = -10000000;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif


#if INPUT_FROM_FILE
	ifs >> n;
#else
	std::cin >> n;
#endif
	A.resize(n, std::vector<int>(n, 0));
	S.resize(n + 1, std::vector<int>(n, 0));

	for(int y = 0; y < n; y++){
		for(int x = 0; x < n; x++){
#if INPUT_FROM_FILE
			ifs >> A[y][x];
#else
			std::cin >> A[y][x];
#endif
		}
	}

	for(int x = 0; x < n; x++){
		S[1][x] = A[0][x];
	}

	for(int y = 1; y < n; y++){
		for(int x = 0; x < n; x++){
			S[y + 1][x] = S[y][x] + A[y][x];
		}
	}

	for(int y = 0; y < n; y++){
		dp.clear();
		dp.resize(n, 0);
		dp[0] = A[y][0];
		for(int x = 1; x < n; x++){
			dp[x] = std::max(dp[x - 1] + A[y][x], A[y][x]);
		}
		result = std::max(result, *std::max_element(dp.begin(), dp.end()));
	}

	for(int r0 = 0; r0 < n; r0++){
		for(int r1 = r0 + 1; r1 < n; r1++){
			std::vector<int> a(n, 0);

			for(int x = 0; x < n; x++){
				a[x] = S[r1 + 1][x] - S[r0][x];
			}
			dp.clear();
			dp.resize(n, 0);
			dp[0] = a[0];
			for(int x = 1; x < n; x++){
				dp[x] = std::max(dp[x - 1] + a[x], a[x]);
			}
			result = std::max(result, *std::max_element(dp.begin(), dp.end()));
		}
	}

	std::cout << result << std::endl;
#if INPUT_FROM_FILE
	//fclose(fp);
#endif
	return 0;
}
