#include <iostream>
#include <cstdio>
#include <cmath>
#include <climits>

using namespace std;

bool **input(int n){
    bool **x = new bool*[n];
    for(int i = 0; i < n; i++){
        x[i] = new bool[60];
        unsigned long long t;
        scanf("%d", &t);
        for(int j = 0; j < 60; j++, t /= 2)
            x[i][j] = t%2;
    }
    return x;
}

int main(){
    int n;
    bool **x;
    cin >> n;
    x = input(n);

    int a[60];
    for(int i = 0; i < 60; i++){
        a[i] = 0;
        for(int j = 0; j < n; j++)
            if(!x[j][i])
                a[i]++;
    }
    unsigned long long m = a[0], p = 0;
    for(unsigned long long i = 1, j = 2; i < 60; i++, j *= 2)
        if(m >= a[i] * j){
            p = i;
            m = a[i] * j;
        }
    bool t = m == 0;
    if(n%2 == 1)
        cout << m;
    else{
        bool s = false;
        for(int i = 0; i < 60 && !s; i++)
            s = a[i]%2;
        for(int i = 0; i < n && !s; i++){
            int j;
            for(j = p + 1; !x[i][j] && j < 60; j++);
            s = x[i][j];
        }
        if(s)
            cout << m;
        else{
            unsigned long long m1 = ULLONG_MAX;
            for(unsigned long long i = 0, j = 1; i < 60; i++, j *= 2){
                if(i == p)
                    continue;
                m1 = min(m1, a[i]%2*j);
            }
            cout << m + m1;
        }
    }

    for(int i = 0; i < n; i++)
        delete[] x[i];
    delete[] x;
    return 0;
}