#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  ll ans = 2e18;
  for (int bit = 0; bit < (1 << n); ++bit) {
    vector<ll> v;
    ll sum = 0;
    for (int i = 0; i < n; ++i) {
      if (bit >> i & 1) {
        v.push_back(sum);
        sum = a[i];
      } else {
        sum |= a[i];
      }
    }
    v.push_back(sum);
    ll res = 0;
    for (int i = 0; i < v.size(); ++i) {
      res ^= v[i];
    }
    ans = min(ans, res);
  }
  cout << ans << endl;
  return 0;
}

#include <bits/stdc++.h>

using namespace std;

using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;
using isize = ptrdiff_t;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using usize = size_t;

using f32 = float_t;
using f64 = double_t;

i32 n;
vector<i64> a;
i64 ans = 1e18;


void solve(i32 p, i64 Or, i64 Xor) {
    if (p == n) {
        ans = min(Xor ^ Or, ans);
        return;
    }

    Or |= a[p];
    solve(p + 1, Or, Xor);
    solve(p + 1, 0, Xor ^ Or);
}

auto main() -> i32 {

    ios::sync_with_stdio(false), cin.tie(nullptr);

    cin >> n;
    a.resize(n);
    for (auto& x : a) {
        cin >> x;
    }

    solve(0, 0, 0);
    cout << ans;
    cout << "\n";

    return 0;
}