import java.io.*; import java.util.*; import java.util.Map.*; public class Main_yukicoder698 { private static Scanner sc; private static Printer pr; private static void solve() { int n = sc.nextInt(); int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = sc.nextInt(); } Map hm = new HashMap<>(); // nn個のビットのうち、ii個のビットが立っているmaskのパターンの生成 int nn = n; int ii = 2; int mask = (0x1 << ii) - 1; while (mask < 0x1 << nn) { // maskに対する処理 long tmp = 0; for (int j = 0; j < n; j++) { if ((mask & 0x1 << j) != 0) { tmp ^= a[j]; } } hm.put(mask, tmp); // 次のmaskの計算 int xx = mask & -mask; int yy = mask + xx; mask = ((mask & ~yy) / xx >> 1) | yy; } Map hm2 = new HashMap<>(hm); for (int i = 4; i <= n; i += 2) { Map hmtmp = new HashMap<>(); for (Entry e : hm.entrySet()) { int key = e.getKey(); long value = e.getValue(); for (Entry ee : hm2.entrySet()) { int nkey = key | ee.getKey(); if (Integer.bitCount(nkey) != i) { continue; } if (!hmtmp.containsKey(nkey)) { hmtmp.put(nkey, 0L); } hmtmp.put(nkey, Math.max(hmtmp.get(nkey), value + hm2.get(ee.getKey()))); } } hm2 = hmtmp; } pr.println(hm2.get((0x1 << n) - 1)); } // --------------------------------------------------- public static void main(String[] args) { sc = new Scanner(INPUT == null ? System.in : new ByteArrayInputStream(INPUT.getBytes())); pr = new Printer(System.out); solve(); // pr.close(); pr.flush(); // sc.close(); } static String INPUT = null; private static class Printer extends PrintWriter { Printer(OutputStream out) { super(out); } } }