#include <bits/stdc++.h>
#define maxn 500010
#define maxa 64
using namespace std;

unsigned long long n, andS, xorS, ans, a[maxn], cNum0[maxa], cNum1[maxa];

int main()
{
    ios_base::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
    cin >> n;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        if(!i){
            andS = a[0];
            xorS = a[0];
        } else {
            andS &= a[i];
            xorS ^= a[i];
        }
        for(int j = 0; j < maxa; ++j){
            if(a[i] & (1LL<<j)){
                cNum1[j]++;
            } else {
                cNum0[j]++;
            }
        }
    }
    if(andS != 0 and xorS != 0){
        cout <<0;
        return 0;
    }
    ans = 1e18;
    if(n % 2 == 1){
        for(int i =0; i < maxa; ++i){
            if(ans < (1LL<<i)){
                break;
            }
            ans = min(ans, cNum0[i]*(1LL<<i));
        }
    } else {
        for(int i = 0; i < maxa; ++i){
            unsigned long long tmp;
            if(cNum1[i] & 1){
                tmp = 0;
            } else {
                tmp = (1LL<<i);
            }
            for(int j = 0; j < maxa; ++j){
                if(i == j){
                    continue;
                }
                if(ans < tmp + (1LL<<j)){
                    break;
                }
                ans = min(ans, tmp + (1LL<<j)*cNum0[j]);
            }
        }
    }
    cout << ans;
    return 0;
}