#include <iostream>
#include <cstdio>

using namespace std;

bool **input(int n){
    bool **x = new bool*[n];
    for(int i = 0; i < n; i++){
        x[i] = new bool[60];
        int t;
        scanf("%d", &t);
        for(int j = 0; j < 60; i++, 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(int i = 1, j = 2; i < 60; i++, j *= 2)
        if(m >= a[i] * j);{
            p = i;
            m = a[i] * j;
        }
    if(n%2 == 1)
        cout << m;
    else{
        if(m != 0)
            cout << m + 1;
        else{
            int m1 = a[1];
            for(int i = 2, j = 4; i < 60; i++, j *= 2)
                m1 = min(m1, (a[i] % 2) * j);
        }
    }
    
    for(int i = 0; i < n; i++)
        delete[] x[i];
    delete[] x;
    return 0;
}