#include <bits/stdc++.h>

using namespace std;

bool mat[500000][15] = {{0}};
int maxind = INT_MIN;
long long br[500000];
void binarno(long long k, int ind)
{
    int i = 0;
    while(k > 0)
    {
        //cout << i << "i ";
        if(k % 2 == 0)
            mat[ind][i] = 0;
        else
            mat[ind][i] = 1;
        k /= 2;
        //cout << k;
        i++;
        if(i > maxind)
            maxind = i;
    }

}
int n;
int bio[500000] = {0};
int maks = INT_MAX;
void din(int i)
{
    vector<int> xo;
    int res1 = 0;
    int res0 = 0;
    for(int j= 0; j < n; j++)
    {
       // cout << mat[j][i] << " ";
        if(mat[j][i] == 0)
        {
            //cout << i << " ";
            res1 += (pow(2, i) - bio[j]);
            xo.push_back(br[j] - bio[j] + pow(2, i));
        }
        else
        {
            xo.push_back(br[j]);
        }
    }
    int rez = xo[0];
    for(int j = 1; j < n; j++)
        rez = (rez ^ xo[j]);
    if(rez != 0)
    {
        if(res1 < maks)
            maks = res1;
    }
}




int main()
{
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> br[i];
       // cout << br[i];
        binarno(br[i], i);
    }
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < maxind; j++)
            cout << mat[i][j] << " ";
        cout << endl;
    }
    for(int i = 0; i <= maxind; i++)
    {

        din(i);
        for(int j = 0; j < n; j++)
        {
            if(mat[j][i] == 1)
                bio[j] += pow(2, i);
        }
    }
    cout << maks;
    return 0;
}