import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); ArrayList list = new ArrayList<>(); for (int i = 0; i < n; i++) { list.add(sc.nextInt()); } System.out.println(getAnswer(30, list)); } static int getAnswer(int idx, ArrayList list) { int mask = (1 << idx); ArrayList on = new ArrayList<>(); ArrayList off = new ArrayList<>(); for (int x : list) { if ((mask & x) == 0) { off.add(x); } else { on.add(x); } } if (on.size() > 0 && off.size() > 0) { if (idx == 0) { return 1; } else { return mask + Math.min(getAnswer(idx - 1, on), getAnswer(idx - 1, off)); } } else if (on.size() > 0) { if (idx == 0) { return 0; } else { return getAnswer(idx - 1, on); } } else { if (idx == 0) { return 0; } else { return getAnswer(idx - 1, off); } } } }