import java.util.*; public class Main { static int[][] matrix; static int n; static HashMap map = new HashMap<>(); public static void main(String[] args) { Scanner sc = new Scanner(System.in); n = sc.nextInt(); matrix = new int[n][n]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { matrix[i][j] = sc.nextInt(); } } System.out.println(getCount(0)); } static int getCount(int key) { if (key == (int)(Math.pow(2, n)) - 1) { return 0; } if (map.containsKey(key)) { return map.get(key); } int max = 0; for (int i = 0; i < n; i++) { if (((int)(Math.pow(2, i)) & key) != 0) { continue; } for (int j = i + 1; j < n; j++) { if (((int)(Math.pow(2, j)) & key) != 0) { continue; } max = Math.max(max, matrix[i][j] + getCount(key + (int)(Math.pow(2, i)) + (int)(Math.pow(2, j)))); } } map.put(key, max); return max; } }