#include <bits/stdc++.h>
const int mod = 1000000;
using namespace std;
const int maxn = 1e5 + 10;
vector<int> a;
int n;
int dfs(vector<int>& a, int now) {
  if (now < 0) return 0;
  vector<int> b, c;
  for (auto i : a) {
    if (((i >> now) & 1) == 1)
      b.push_back(i);
    else
      c.push_back(i);
  }
  int ans = 0;
  if (b.size() == 0)
    ans += dfs(c, now - 1);
  else if (c.size() == 0)
    ans += dfs(b, now - 1);
  else {
    ans += min(dfs(c, now - 1), dfs(b, now - 1)) + (1 << now);
  }
  return ans;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int now;
    cin >> now;
    a.push_back(now);
  }
  int ans = dfs(a, 30);
  cout << ans << endl;
  return 0;
}
