import java.io.*; import java.util.*; public class Main_yukicoder130_1 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); Printer pr = new Printer(System.out); int n = sc.nextInt(); SortedSet a = new TreeSet<>(); for (int i = 0; i < n; i++) { a.add(sc.nextInt()); } pr.println(rec(0, 0, 0, a)); pr.close(); sc.close(); } private static int rec(int mask, int bit, int max, SortedSet a) { if (mask == 0x7fffffff) { return max; } int nmask = mask >>> 1 | 0x40000000; int nbit = ((~mask & 0x7fffffff) + 1) >>> 1; int to1 = (~nmask & 0x7fffffff | bit) + 1; int to2 = (~nmask & 0x7fffffff | bit | nbit) + 1; if (to1 < 0) { to1 = Integer.MAX_VALUE; } if (to2 < 0) { to2 = Integer.MAX_VALUE; } SortedSet a1 = a.subSet(bit, to1); SortedSet a2 = a.subSet(bit | nbit, to2); if (a1.size() == 0 && a2.size() == 0) { return Integer.MAX_VALUE; } else if (a2.size() == 0) { return rec(nmask, bit, max, a); } else if (a1.size() == 0) { return rec(nmask, bit | nbit, max, a); } else { return Math.min(rec(nmask, bit, max | nbit, a), rec(nmask, bit | nbit, max | nbit, a)); } } @SuppressWarnings("unused") private static class Scanner { BufferedReader br; Iterator it; Scanner (InputStream in) { br = new BufferedReader(new InputStreamReader(in)); } String next() throws RuntimeException { try { if (it == null || !it.hasNext()) { it = Arrays.asList(br.readLine().split(" ")).iterator(); } return it.next(); } catch (IOException e) { throw new IllegalStateException(); } } int nextInt() throws RuntimeException { return Integer.parseInt(next()); } long nextLong() throws RuntimeException { return Long.parseLong(next()); } float nextFloat() throws RuntimeException { return Float.parseFloat(next()); } double nextDouble() throws RuntimeException { return Double.parseDouble(next()); } void close() { try { br.close(); } catch (IOException e) { // throw new IllegalStateException(); } } } private static class Printer extends PrintWriter { Printer(PrintStream out) { super(out); } } }