#include <bits/stdc++.h>
using namespace std;
const int nax = 1e7;
const int mod = 1e9 + 7;
int Dr(vector<int> v, int pos) {
  if (pos < 0) {
    return 0;
  }
  vector<int> ones, zeros;
  for (auto x : v) {
    if ((x >> pos) & 1) {
      ones.push_back(x);
    } else {
      zeros.push_back(x);
    }
  }
  if (ones.empty()) {
    return Dr(zeros, pos - 1);
  } else if (zeros.empty()) {
    return Dr(ones, pos - 1);
  }
  return min(Dr(ones, pos - 1), Dr(zeros, pos - 1)) | (1 << pos);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  };
  cout << Dr(v, 30);
}
