#include <bits/stdc++.h>
using namespace std;
int64_t seed;
mt19937 rng(seed = chrono::steady_clock::now().time_since_epoch().count());
inline int64_t rnd(int64_t l = 0, int64_t r = INT_MAX) {
  return uniform_int_distribution<int64_t>(l, r)(rng);
}
template <typename T, typename G>
ostream &operator<<(ostream &out, const pair<T, G> &a) {
  return out << "( " << a.first << ", " << a.second << ")";
}
template <typename T>
ostream &operator<<(ostream &out, const vector<T> &a) {
  out << "[ ";
  for (const auto &i : a) out << i << ", ";
  return out << "]" << endl;
}
template <typename T>
ostream &operator<<(ostream &out, const set<T> &a) {
  out << "{ ";
  for (const auto &i : a) out << i << ", ";
  return out << "}" << endl;
}
template <typename T, typename G>
ostream &operator<<(ostream &out, const map<T, G> &a) {
  out << "< ";
  for (const auto &i : a) out << i << ", ";
  return out << ">" << endl;
}
template <typename T, size_t N>
typename enable_if<!is_same<typename remove_cv<T>::type, char>::value,
                   ostream &>::type
operator<<(ostream &out, T (&a)[N]) {
  out << "[ ";
  for (size_t i = 0; i < N; ++i) out << a[i] << ", ";
  out << "]" << endl;
  return out;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << (H) << " ";
  debug_out(T...);
}
int64_t go(int64_t i, vector<int64_t> &a) {
  if (i < 0) return 0;
  24;
  vector<int64_t> z, o;
  for (auto &c : a) {
    if (c & (1LL << i))
      o.push_back(c);
    else
      z.push_back(c);
  }
  if (o.size() == 0)
    return go(i - 1, z);
  else if (z.size() == 0)
    return go(i - 1, o);
  else
    return int64_t(1ll << i) | min(go(i - 1, z), go(i - 1, o));
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int64_t n;
  cin >> n;
  vector<int64_t> a(n);
  for (auto &c : a) {
    cin >> c;
  }
  cout << go(30, a) << "\n";
  return 0;
}
