#include <bits/stdc++.h>
using namespace std;
const long long int inf = 1e9 + 7;
const long long int modc = 998244353;
long long int maxi(long long int a, long long int b) {
  if (a >= b) return a;
  return b;
}
long long int mini(long long int a, long long int b) {
  if (a >= b) return b;
  return a;
}
long long int solve(vector<long long int> &B, long long int bit) {
  if (bit < 0) return 0;
  vector<long long int> on, off;
  for (auto &i : B) {
    if ((i >> bit) & 1)
      on.push_back(i);
    else
      off.push_back(i);
  }
  if (on.size() == 0) return solve(off, bit - 1);
  if (off.size() == 0) return solve(on, bit - 1);
  return mini(solve(on, bit - 1), solve(off, bit - 1)) + (1 << bit);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  long long int n;
  cin >> n;
  vector<long long int> A(n);
  for (long long int i = 0; i < n; i++) cin >> A[i];
  cout << solve(A, 30);
  return 0;
}
