import java.util.*; public class Main { static int[] base; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); base = new int[31]; base[0] = 1; for (int i = 1; i < base.length; i++) { base[i] = base[i - 1] * 2; } HashSet set = new HashSet<>(); for (int i = 0; i < n; i++) { set.add(sc.nextInt()); } System.out.println(getMin(30, set)); } static int getMin(int idx, HashSet set) { if (idx == 0) { if(set.size() == 1) { return 0; } else { return 1; } } HashSet next = new HashSet<>(); for (int x : set) { if (x >= base[idx]) { next.add(x); } } if (next.size() == 0) { return getMin(idx - 1, set); } else if (next.size() == set.size()) { HashSet tmp = new HashSet<>(); for (int x : next) { tmp.add(x - base[idx]); } return getMin(idx - 1, tmp); } else { HashSet tmp = new HashSet<>(); for (int x : next) { tmp.add(x - base[idx]); set.remove(x); } return base[idx] + Math.min(getMin(idx - 1, set), getMin(idx - 1, tmp)); } } }