#include <bits/stdc++.h>
using namespace std;
bool compare(const pair<int, int> &a, const pair<int, int> &b) {
  return a.second < b.second;
}
template <typename T>
string to_str(T str) {
  stringstream stream;
  stream << str;
  return stream.str();
}
long long f(int bit, vector<long long> &arr) {
  if (bit < 0) return 0;
  vector<long long> on, off;
  for (int i = 0; i < arr.size(); i++) {
    if (arr[i] & (1 << bit))
      on.push_back(arr[i]);
    else
      off.push_back(arr[i]);
  }
  if (on.size() * off.size() == 0) return f(bit - 1, arr);
  return (long long)(pow(2, bit)) + min(f(bit - 1, on), f(bit - 1, off));
}
int main() {
  int n;
  cin >> n;
  vector<long long> arr(n);
  long long maxi = 0;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    maxi = max(arr[i], maxi);
  }
  int setMSB = (int)(log2(maxi));
  cout << f(setMSB, arr) << endl;
}
