#include <bits/stdc++.h> 

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define LLINF LLONG_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < n; i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;

    vector<ll> A(N);
    rep (i, N) {
        cin >> A[i];
    }

    ll ans = INF;
    rep (bit, (1<<(N-1))) {
        ll xored = 0;
        ll ored = 0;

        rep (i, N+1) {
            if (i < N) {
                ored |= A[i];
            }
            if ((bit & (1<<i)) || (i == N)) {
                xored ^= ored;
                ored = 0;
            }
        }

        ans = min(ans, xored);
    }

    cout << ans << endl;
    return 0;
}
#include <bits/stdc++.h>
using namespace std;
using ll         = long long;
constexpr ll MOD = 1000000007;
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REP2(i, x, n) for (ll i = x; i < (n); i++)
#define PR(x) cout << (x) << "\n"
#define PS(x) cout << (x) << " "
#define PRYES(x) PR((x) ? "Yes" : "No")
const long long INF          = numeric_limits<long long>::max();
const long long DP_INF       = 1 << 29;
template <class T> using arr = vector<vector<T> >;
using vint                   = vector<int>;
using vll                    = vector<ll>;
// SourceTest用出力マクロ
#ifdef SOURCE_TEST
#define SPR(x) PR(x)
#define SPS(x) PS(x)
#define STRACE(var) cout << #var << "=" << var << endl;
#define SMAPTRACE(var)  \
    cout << #var << "=" \
         << "{" << var.first << "," << var.second << "}" << endl;
#else
#define SPR(x) \
    {}
#define SPS(x) \
    {}
#define STRACE(var) \
    {}
#define SMAPTRACE(var) \
    {}
#endif
template <class T> void dump(const vector<T>& vec) {
#ifdef SOURCE_TEST
    for (ll i = 0; i < vec.size(); ++i) {
        cout << vec[i] << ",";
    }
    cout << endl;
#endif
}

vector<vll> orNums;

int main() {
    ll N;
    cin >> N;
    vll values(N);
    REP(i, N) {
        cin >> values[i];
    }
    orNums.resize(N);
    vector<vll> xorNums(N);
    orNums[0].resize(N);
    for (ll s = 0; s < N; ++s) {
        orNums[0][s] |= values[s];
    }
    for (ll i = 1; i < N; ++i) {
        orNums[i].resize(N, 0);
        for (ll s = 0; s < N; ++s) {
            ll n = s + i;
            if (n >= N) continue;
            orNums[i][s] = orNums[i - 1][s] | orNums[0][n];
        }
    }

    SPR("orList");
    for (const auto& ss : orNums) {
        dump(ss);
    }

    struct INFO {
        ll value;
        ll remainNum;
        ll next;

        void dump() const {
            SPS(value);
            SPS(remainNum);
            SPR(next);
            SPR("---");
        }
    };
    queue<INFO> infos;
    for (ll i = 0; i < N; ++i) {
        infos.push({orNums[i][0], N - 1 - i, i + 1});
    }

    ll ans = INF;
    while (!infos.empty()) {
        auto info = infos.front();
        infos.pop();
        SPR("------dumpInfomation");
        info.dump();
        if (info.remainNum == 0) {
            ans = min(ans, info.value);
        } else {
            for (ll i = 0; i < N; ++i) {
                ll nextValue = orNums[i][info.next];
                ll nextR     = info.remainNum - i - 1;
                if (nextR >= 0) {
                    INFO infomation;
                    infomation.value     = info.value ^ nextValue;
                    infomation.remainNum = nextR;
                    infomation.next      = info.next + 1 + i;
                    STRACE(i);
                    STRACE(nextValue);
                    infomation.dump();
                    infos.push(infomation);
                }
            }
        }
    }

    PR(ans);
    return 0;
}