#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
template <class T1, class T2, class T3>
inline T3 bigMod(T1 b, T2 p, T3 M) {
  if (!p) return 1;
  if (p & 1) return b * bigMod(b, p - 1, M) % M;
  T3 h = bigMod(b, p >> 1, M);
  return h * h % M;
}
template <class T1, class T2>
inline T2 modInverse(T1 a, T2 M) {
  return bigMod(a % M, M - 2, M);
}
template <class T>
inline T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
inline T lcm(T a, T b) {
  return (a / gcd(a, b)) * b;
}
template <class T>
inline string int2String(T a) {
  ostringstream str;
  str << a;
  return str.str();
}
int cal(int pos, vector<int>& v) {
  if (pos < 0 || v.empty()) return 0;
  vector<int> on, off;
  for (const int& x : v) {
    if (((bool)(x & (1LL << (pos)))))
      on.push_back(x);
    else
      off.push_back(x);
  }
  v.clear();
  if (on.empty()) return cal(pos - 1, off);
  if (off.empty()) return cal(pos - 1, on);
  return min(cal(pos - 1, on), cal(pos - 1, off)) + (1 << pos);
}
int main() {
  int n;
  scanf("%d", &n);
  vector<int> v(n);
  for (int i = int(0); i < int(n); i++) scanf("%d", &v[i]);
  printf("%d\n", cal(30, v));
  return 0;
}
