#include <bits/stdc++.h>
using namespace std;
long long int solve(long long int pos, long long int n,
                    vector<long long int> &v) {
  if (pos < 0) return 0;
  vector<long long int> on, off;
  for (long long int i = 0; i < n; i++) {
    if ((1 << pos) & v[i])
      on.push_back(v[i]);
    else
      off.push_back(v[i]);
  }
  if (on.size() == 0 || off.size() == 0)
    return solve(pos - 1, n, v);
  else {
    return min(solve(pos - 1, on.size(), on), solve(pos - 1, off.size(), off)) +
           (1 << pos);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n;
  cin >> n;
  vector<long long int> v(n);
  for (long long int i = 0; i < n; i++) cin >> v[i];
  ;
  long long int lar = 0;
  long long int ans = solve(30, n, v);
  cout << ans << '\n';
  return 0;
}
