import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); HashSet list = new HashSet<>(); for (int i = 0; i < n; i++) { list.add(sc.nextInt()); } System.out.println(getMin(30, list)); } static int getMin(int idx, HashSet list) { if (idx < 0) { return 0; } HashSet odd = new HashSet<>(); HashSet even = new HashSet<>(); for (int x : list) { if ((x & (1 << idx)) == 0) { even.add(x); } else { odd.add(x ^ (1 << idx)); } } if (even.size() == 0) { return getMin(idx - 1, odd); } else if (odd.size() == 0) { return getMin(idx - 1, even); } else { return (1 << idx) + Math.min(getMin(idx - 1, even), getMin(idx - 1, odd)); } } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); 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 nextLine() throws Exception { return br.readLine(); } public String next() throws Exception { if (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }