#include <bits/stdc++.h>
using namespace std;
vector<long long int> p;
long long first(vector<long long int> v, long long b) {
  if (b < 0) return 0;
  vector<long long int> o, z;
  for (auto it : v) {
    if (it & (1ll << b))
      o.push_back(it);
    else
      z.push_back(it);
  }
  if (!((long long int)(z).size())) return first(o, b - 1);
  if (!((long long int)(o).size())) return first(z, b - 1);
  return min(first(o, b - 1), first(z, b - 1)) + p[b];
}
void solve() {
  long long n;
  cin >> n;
  vector<long long int> a(n);
  for (auto &it : a) cin >> it;
  p.push_back(1);
  for (long long i = 1; i <= 60; i++)
    p.push_back(p[((long long int)(p).size()) - 1] * 2);
  cout << first(a, 60);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  long long t = 1;
  while (t--) {
    solve();
    cout << "\n";
  }
  cin.get();
  return 0;
}
