#include <bits/stdc++.h>

#define int long long
#define x first 
#define y second
using namespace std;

void solve()
{
    int N; cin>>N; 

    int a[N]; 
    for(int i = 0; i<N; i++)
        cin>>a[i];

    int res = INT_MAX;
    for(int i = 0; i<1<<(N-1); i++){

        int ored = 0; 
        int xored = 0;

        for(int j = 0; j<=N; j++){
            if(j<N){
                ored |=  a[j];
            }
            if(j==N || (i>>j) & 1){
                // if we are at the end or there is a 
                // bar at the j-th position.
                xored ^= ored; 
                ored = 0;
            }
        }
        res = min(res,xored);
    }
    cout<<res<<endl;
}
signed main(){ 
    int T=1; //cin>>T; 
    while(T--){
        solve();
    }
}




















#include<iostream>
#include<vector>
using namespace std;

int main(){
    int N;
    cin >> N;
    int n = 0;
    for (int i = 0; i < N; i++){
        int ai;
        cin >> ai;
        if (ai > 10){
            n += ai - 10;
        }
    }
    cout << n << endl;
}