#include <bits/stdc++.h>
using namespace std;
long long int n;
vector<long long int> v;
long long int maxxor(int i, int j, int bit) {
  if (bit == -1) return 0;
  for (int k = i; k <= j; k++) v[k] = v[k] % (1ll << (bit + 1));
  sort(v.begin() + i, v.begin() + j + 1);
  long long int idx =
      lower_bound(v.begin() + i, v.begin() + j + 1, 1ll << bit) - v.begin();
  if (idx == i or idx == j + 1) return maxxor(i, j, bit - 1);
  return (1ll << bit) +
         min(maxxor(i, idx - 1, bit - 1), maxxor(idx, j, bit - 1));
}
int main() {
  cin >> n;
  v.assign(n + 1, 0);
  for (int i = 1; i <= n; i++) cin >> v[i];
  sort(v.begin(), v.end());
  cout << (long long int)maxxor(1, n, 30);
}
