#include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 5, mod = 1e9 + 7;
int solve(vector<int> v, int bit) {
  if (bit == 0) {
    int cnt = 0;
    for (auto i : v) {
      if (i & 1) cnt++;
    }
    if (cnt == 0 || cnt == v.size()) return 0;
    return 1;
  }
  vector<int> v2[3];
  for (auto i : v) {
    if (i >> bit & 1)
      v2[1].push_back(i);
    else
      v2[0].push_back(i);
  }
  if (v2[0].size() == 0) return solve(v2[1], bit - 1);
  if (v2[1].size() == 0) return solve(v2[0], bit - 1);
  return min(1 << bit | solve(v2[0], bit - 1),
             1 << bit | solve(v2[1], bit - 1));
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  cout << solve(v, 30);
  return 0;
}
