import java.io.*; import java.util.*; public class Main { static boolean[][] dp; static boolean[][] visited; static int[] values; public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); if (n >= 16) { System.out.println((1 << 16) - 1); return; } values = new int[n]; for (int i = 0; i < n; i++) { values[i] = sc.nextInt(); } dp = new boolean[n][1 << 16]; visited = new boolean[n][1 << 16]; for (int i = (1 << 16) -1; i > 0; i--) { if (dfw(n - 1, i)) { System.out.println(i); return; } } } static boolean dfw(int idx, int mask) { if (mask == 0) { return true; } if (idx < 0) { return false; } if (visited[idx][mask]) { return dp[idx][mask]; } visited[idx][mask] = true; int value = values[idx]; for (int i = 0; i < 16; i++) { dp[idx][mask] = dfw(idx - 1, mask ^ (mask & value)); if (dp[idx][mask]) { return true; } value = next(value); } return dp[idx][mask]; } static int next(int x) { return (x >> 1) + (1 << 15) * (x % 2); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }