#include <bits/stdc++.h>
using namespace std;
struct tree {
  tree* l;
  tree* r;
  long long cnt;
  tree() {
    l = NULL;
    r = NULL;
    cnt = 0;
  }
};
tree* top = new tree();
void add(long long x) {
  tree* cur = top;
  for (long long i = 29; i >= 0; i--) {
    if (x & (1 << i)) {
      if (!cur->r) cur->r = new tree();
      cur = cur->r;
    } else {
      if (!cur->l) cur->l = new tree();
      cur = cur->l;
    }
  }
}
long long solve(tree* cur, long long bits = 29) {
  if (cur->l && cur->r) {
    return min(solve(cur->l, bits - 1), solve(cur->r, bits - 1)) +
           (1ll << bits);
  } else if (cur->r) {
    return solve(cur->r, bits - 1);
  } else if (cur->l) {
    return solve(cur->l, bits - 1);
  } else {
    return 0;
  }
}
signed main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(0);
  ;
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (auto& z : a) {
    cin >> z;
    add(z);
  }
  cout << solve(top);
  return 0;
}
