#include <bits/stdc++.h>
using namespace std;
int n;
int a[100000];
int split(int start, int end, int bitpos) {
  int p1 = start;
  int p2 = start;
  while (p2 < end) {
    if (a[p2] & (1 << bitpos)) {
      swap(a[p1], a[p2]);
      p1++;
    }
    p2++;
  }
  return p1;
}
int ans(int start, int end, int bitpos) {
  if (bitpos < 0) {
    return 0;
  }
  int mid = split(start, end, bitpos);
  if (mid == start || mid == end) {
    return ans(start, end, bitpos - 1);
  } else {
    return (1 << bitpos) +
           min(ans(start, mid, bitpos - 1), ans(mid, end, bitpos - 1));
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  printf("%d\n", ans(0, n, 30));
}
