Matrix of given integers


a1,1 a1,2 ... a1, n
a2,1 a2,2 ... a2, n
::
an, 1 an, 2 ... an, n


Then, create a program that outputs the maximum value of the sum of one or more consecutive terms (submatrix) in the vertical and horizontal directions and ends.



Input

The input data is given in the following format.


n
a1,1 a1,2 ... a1, n
a2,1 a2,2 ... a2, n
::
an, 1 an, 2 ... an, n


n is 1 or more and 100 or less, and ai, j is -10000 or more and 10000 or less.

Output

Print the maximum value on one line.

Examples

Input

3
1 -2 3
-4 5 6
7 8 -9


Output

16


Input

4
1 3 -9 2
2 7 -1 5
-8 3 2 -1
5 0 -3 1


Output

15
#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;
}
