#include <bits/stdc++.h>
using namespace std;
int Solve(vector<int> &a, int k = 29) {
  if (a.size() < 2) {
    return 0;
  }
  const int powerMask = (1 << k), allOnesMask = (1 << k) - 1;
  vector<int> zeros, ones;
  for (int x : a) {
    if ((x & powerMask) > 0) {
      ones.push_back((x & allOnesMask));
    } else {
      zeros.push_back(x);
    }
  }
  a.clear();
  if (zeros.empty()) {
    return Solve(ones, k - 1);
  }
  if (ones.empty()) {
    return Solve(zeros, k - 1);
  }
  return powerMask + min(Solve(zeros, k - 1), Solve(ones, k - 1));
}
int main() {
  int n;
  vector<int> a;
  scanf("%d", &n);
  while (n--) {
    int x;
    scanf("%d", &x);
    a.push_back(x);
  }
  sort(a.begin(), a.end());
  a.erase(unique(a.begin(), a.end()), a.end());
  printf("%d\n", Solve(a));
  return 0;
}
