#include <bits/stdc++.h>
using namespace std;
vector<int> v[33];
long long f(int i, int l, int r) {
  if (i == 0) {
    int x = -1;
    for (int j = l; j <= r; j++) {
      if (v[i][j]) {
        x = j;
        break;
      }
    }
    if (x == l || x == -1) {
      return 0;
    } else {
      return 1;
    }
  }
  if (v[i][l] == 1 || v[i][r] == 0) {
    return f(i - 1, l, r);
  } else {
    int x = -1;
    for (int j = l; j <= r; j++) {
      if (v[i][j]) {
        x = j;
        break;
      }
    }
    if (x == -1) {
      cout << "NO\n";
    }
    long long res = (1LL << i);
    return res + min(f(i - 1, l, x - 1), f(i - 1, x, r));
  }
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  vector<long long> vv(n);
  for (int i = 0; i < n; i++) {
    cin >> vv[i];
  }
  sort(vv.begin(), vv.end());
  for (int i = 0; i < n; i++) {
    for (long long j = 31; j >= 0; j--) {
      v[j].push_back((vv[i] >> j) & 1);
    }
  }
  cout << f(31, 0, n - 1) << endl;
  return 0;
}
