// Arup Guha
// 3/2/2021
// Solution to 2021 January USACO Silver Problem: Spaced Out

/*** The key observation here is that in the top left 2 x 2 corner, we have
     these options:
	 
	 x x	or	x _	or 	x _	  or _ x   or  _ x	or _ _
	 _ _        x _     _ x      x _       _ x     x x
	 
	 in all instances either we can view each of the first two rows as having
	 1 item, OR each of the first two columns. In the row view (middle four)
	 if we sweep across the row, we are forced to have the items spaced out on
	 every other column. In the column view (first and last), we are forced when
	 going down and filling out items to have every other row in a column. So,
	 any valid solution must have the property that on each ROW we choose the
	 even or odd indexed values OR on each column, we choose the even or odd
	 indexed values. So, I try both for each row, and then do so for columns by
	 repeating the same steps on the transpose.
***/

import java.util.*;
import java.io.*;

public class spacedout {

	public static int n;
	
	public static void main(String[] args) throws Exception {
	
		BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer tok = new StringTokenizer(stdin.readLine());
		n = Integer.parseInt(tok.nextToken());
		
		// Read grid.
		int[][] arr = new int[n][n];
		for (int i=0; i<n; i++) {
			tok = new StringTokenizer(stdin.readLine());
			for (int j=0; j<n; j++)
				arr[i][j] = Integer.parseInt(tok.nextToken());
		}
			
		// Solve with the regular array.
		int res1 = solveRows(arr);
		
		// And the transpose and take the best answer.
		int[][] arr2 = transpose(arr);
		int res2 = solveRows(arr2);
		System.out.println(Math.max(res1, res2));
	}
	
	// Returns the transpose of a. a must be n by n.
	public static int[][] transpose(int[][] a) {
		int[][] b = new int[n][n];
		for (int i=0; i<n; i++)
			for (int j=0; j<n; j++)
				b[i][j] = a[j][i];
		return b;
	}
	
	public static int solveRows(int[][] a) {
	
		int res = 0;
		
		// Go through each row.
		for (int i=0; i<n; i++) {
		
			// Sum even and odd indexed values on the row.
			int oSum = 0, eSum = 0;
			for (int j=0; j<n; j++) {
				if (j%2 == 0) 	eSum += a[i][j];
				else			oSum += a[i][j];
			}
			
			// Just do the best of these two.
			res += Math.max(eSum, oSum);
		}
	
		return res;
	}
}