#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
const int MOD = 1e9 + 7;
const long double PI = 3.1415926535898;
const long long INF = LLONG_MAX;
int n;
int a[(int)1e6 + 5];
vector<int> elements;
int ans(int pos) {
  if (pos < 0) return 0;
  vector<int> on, off;
  for (int i = 0; i < elements.size(); i++) {
    if (elements[i] & (1 << pos))
      on.push_back(elements[i]);
    else
      off.push_back(elements[i]);
  }
  if (on.size() == 0 || on.size() == elements.size()) {
    return ans(pos - 1);
  }
  elements.clear();
  for (auto v : on) elements.push_back(v);
  int v1 = ans(pos - 1);
  elements.clear();
  for (auto v : off) elements.push_back(v);
  int v2 = ans(pos - 1);
  return (1 << pos) + min(v1, v2);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    elements.push_back(a[i]);
  }
  cout << ans(31) << "\n";
}
