#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define MAXN 500005
#define MAXBIT 50
const ll INF  = 1e18;
ll a[MAXN];
int cnt[MAXBIT];
ll pref[MAXBIT];
ll suff[MAXBIT];

int main()
{
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        for(int j = 0; j < MAXBIT; j++)
        {
            if(a[i]&(1LL<<j))
            {
                cnt[j]++;
            }
        }
    }
    for(int j = 0; j < MAXBIT;j++)
    {
        if(cnt[j]%2==0)
        {
            pref[j]=(1LL<<j);
        }
        else
        {
            pref[j]=0LL;
        }
        if(j>0)pref[j]=min(pref[j],pref[j-1]);
    }
    for(int j = MAXBIT-1; j >= 0; j--)
    {
        if(cnt[j]%2==0)
        {
            suff[j]=(1LL<<j);
        }
        else
        {
            suff[j]=0LL;
        }
        if(j!=MAXBIT-1)suff[j]=min(suff[j],suff[j+1]);
    }
    ll ans = INF;
    for(int j = 0; j < MAXBIT; j++)
    {
        ll tr=0LL;
        for(int i = 0; i < n; i++)
        {
            if(!(a[i]&(1LL<<j)))
            {
                tr+=(1LL)<<j;
            }
        }
        if(n%2==0)
        {
            ll add = INF;
            if(j != 0)add=min(add,pref[j-1]);
            if(j != MAXBIT-1)add=min(add,suff[j+1]);
            tr+=add;
        }
        else
        {

        }
        if(tr < 0)continue;
        ans = min(ans,tr);
    }
    cout << ans;
    return 0;
}