#include <bits/stdc++.h>
using namespace std;
#define idk ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
int n, arr[30];
vector<vector<int>> v;
vector<int> temp;
int solve(int idx, int grp){
    if(idx >= n){
        int xorr = 0;
        for(int i = 0; i < v.size(); i++){
            int orr = 0;
            for(auto j : v[i]) orr |= j;
            xorr ^= orr;
        }
        return xorr;
    }
    int ans = 2e9;
    v[grp].push_back(arr[idx]);
    ans = min(ans, solve(idx + 1, grp));
    ans = min(ans, solve(idx + 1, grp + 1));
    v[grp].pop_back();
    return ans;
}
int main() {
    idk
    cin >> n;
    v.resize(n);
    for(int i = 0; i < n; i++) cin >> arr[i];
    cout << solve(0, 0);
    return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define all(v) v.begin(), v.end()
#define rep(i, begin, end) for(int i = begin; i < (int)(end); i++)
#define contains(v, x) (find(all(v), x) != v.end())
template<class T> bool chmin(T& a, T b){ if (a > b){ a = b; return true; } return false; }
template<class T> bool chmax(T& a, T b){ if (a < b){ a = b; return true; } return false; }
template<class T> T roundup(T a, T b){ return (a + b - 1) / b; }
const double PI = 3.14159265359;
const vector<int> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
const vector<int> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};
/* #include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using d32 = mp::number<mp::cpp_dec_float<32>>; */
using ll = long long;
struct Edge{ int to; ll cost; Edge(int to, ll cost) : to(to), cost(cost) {} };
const ll MOD = (ll)998244353;
const ll INF = (ll)1e9;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
/* #include <atcoder/all>
using namespace atcoder;
using mint = modint; */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    // mint::set_mod(MOD);
    
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, 0, n) cin >> a[i];
    
    if(n == 1){
        cout << a[0] << endl;
        return 0;
    }
    ll ans = INF * INF;
    rep(bit, 1, 1 << (n - 1)){
        vector<ll> temp;
        int b = 0;
        rep(i, 0, n - 1){
            if((bit >> i) & 1){
                ll num = 0;
                rep(j, b, i + 1) num |= a[j];
                temp.emplace_back(num);
                b = i + 1;
            }
        }
        ll add = 0;
        rep(j, b, n) add |= a[j];
        temp.emplace_back(add);
        ll sug = 0;
        for(auto i : temp) sug ^= i;
        chmin(ans, sug);
    }
    cout << ans << endl;
}
