#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <cstdint>
#include <iomanip>
#include <set>
#include <map>
#include <unordered_map>
#include <cassert>
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define fast_io(); std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);

int main(){
    int n;
    std::cin >> n;
    std::vector<int> v(n), o(100001,0), e(100001,0);
    rep(i,n){
        std::cin >> v[i];
        if(i%2) o[v[i]]++;
        else e[v[i]]++;
    }

    auto io = std::distance(o.begin(),std::max_element(o.begin(),o.end()));
    auto ie = std::distance(e.begin(),std::max_element(e.begin(),e.end()));

    std::sort(o.begin(),o.end());
    std::sort(e.begin(),e.end());
    int ans = 0;
    if(io==ie){ //最大の値が同じとき
        ans = std::min(n-o[o.size()-1]-e[e.size()-2],n-o[o.size()-2]-e[e.size()-1]);
    }else{ //最大の値が違うとき
        ans = n - o.back() - e.back();
    }
    std::cout << ans << "\n";
    return 0;
}

#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>

using namespace std;

#define l first
#define r second
#define int long long

int n;
long long a[500000];
vector<long long> multi;

int upper_bit(long long c)
{
    for (int i = 60; i >= 0; i--)
    {
        if (c & (1LL << i)) return i;
    }
    return -1;
}

signed main()
{
    cin >> n;
    long long x = 0;
    for (int i = 0; i < n; i++) cin >> a[i], x ^= a[i];
    for (int i = 0; i < n; i++) a[i] -= a[i] & x;
    for (int i = 0; i < n; i++)
    {
        int kek = 0;
        for (int j = 0; j < multi.size(); j++)
        {
            if (upper_bit(multi[j]) == upper_bit(a[i])) kek = 1;
        }
        if (kek)
        {
            long long cur = a[i];
            for (int i = 0; i < multi.size(); i++)
            {
                if (upper_bit(cur) == upper_bit(multi[i]))
                {
                    cur ^= multi[i];
                    if (cur == 0) break;
                }
            }
            if (cur != 0)
            {
                multi.push_back(cur);
                sort(multi.begin(), multi.end());
                reverse(multi.begin(), multi.end());
            }
        }
        else
        {
            multi.push_back(a[i]);
            sort(multi.begin(), multi.end());
            reverse(multi.begin(), multi.end());
        }
    }
    sort(multi.begin(), multi.end());
    reverse(multi.begin(), multi.end());
    long long res = 0;
    long long b = (1LL << 61);
    for (int i = 0; i < multi.size(); i++)
    {
        //cout << multi[i] << "\n";
        while (b > multi[i]) b /= 2;
        if ((res & b) == 0) res ^= multi[i];
    }
    cout << x + 2 * res;
}
