#include <bits/stdc++.h>
using namespace std;
long long arr[200005], pw[35];
long long solve(vector<long long>& v, int now) {
  if (!v.size() || now == -1) return 0;
  vector<long long> v1, v2;
  for (int i = 0; i < v.size(); i++)
    if ((v[i] & pw[now]) == 0)
      v1.push_back(v[i]);
    else
      v2.push_back(v[i]);
  if (!v1.size())
    return solve(v2, now - 1);
  else if (!v2.size())
    return solve(v1, now - 1);
  return min(solve(v1, now - 1), solve(v2, now - 1)) + pw[now];
}
int main() {
  pw[0] = 1;
  for (int i = 1; i <= 30; i++) pw[i] = pw[i - 1] * 2;
  vector<long long> v;
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &arr[i]);
    v.push_back(arr[i]);
  }
  printf("%lld\n", solve(v, 29));
  return 0;
}
