import java.util.*; import java.io.*; public class Main { static int n; static int[][] dp; static int[] scores; public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); n = Integer.parseInt(br.readLine()); String[] line = br.readLine().split(" ", n); scores = new int[n]; for (int i = 0; i < n; i++) { scores[i] = Integer.parseInt(line[i]); } dp = new int[n / 2 + 1][(int)(Math.pow(2, n))]; System.out.println(dfw(n / 2, (int)(Math.pow(2, n)) - 1)); } static int dfw(int idx, int key) { if (idx == 0) { return 0; } if (dp[idx][key] != 0) { return dp[idx][key]; } int max = 0; for (int i = 0; i < n - 1; i++) { int x = (int)(Math.pow(2, i)); if ((key & x) == 0) { continue; } for (int j = i + 1; j < n; j++) { int y = (int)(Math.pow(2, j)); if ((key & y) == 0) { continue; } max = Math.max(max, dfw(idx - 1, key ^ (x | y)) + (scores[i] ^ scores[j])); } } dp[idx][key] = max; return max; } }