Image recognition, which extracts useful information from images, is one of the important research topics in computer science. It is widely applied in digital cameras, driving assistance systems, and security systems.
Thanks to such research, we can use many software packages and program libraries to perform various image analysis tasks. On the other hand, writing programs ourselves to perform the analysis allows us to understand the underlying mechanisms and enjoy the process. Here, let us try a somewhat unusual form of image recognition.
An image is given as input, consisting of an N × N grid of pixels, where each pixel has an integer value. From this image, extract one rectangular frame whose line thickness is one pixel.
Write a program that extracts the frame whose sum of pixel values is maximized and reports that sum. Note that, as shown in the figure below, a frame is also considered valid when it has only one or two pixels in either the vertical or horizontal direction.
The input is given in the following format.
N p1,1 p1,2 ... p1,N p2,1 p2,2 ... p2,N : pN,1 pN,2 ... pN,N
The first line contains the number of pixels in the vertical and horizontal directions, N (1 ≤ N ≤ 300). The following N lines each contain the integer value pi,j (-1000 ≤ pi,j ≤ 1000) of the pixel in the i-th row and j-th column.
Output the sum of the pixel values of the frame that maximizes this sum on a single line.
5 2 0 0 2 0 0 1 0 2 0 0 0 0 -1 0 0 4 0 3 0 -1 0 0 1 0
12
3 0 0 0 0 -1 0 0 0 0
0