#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
const double PI  =3.141592653589793238463;
using namespace std;
using ll = long long;
const ll INF = +10010010000;
typedef pair<int,int> P;
const int mod = 1e9+7;

struct mint{
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a){
        (x+=a.x)%=mod;
        return *this;
    }
    mint& operator-=(const mint a){
        (x-=mod-a.x)%=mod;
        return *this;
    }
    mint& operator*=(const mint a){
        (x *= a.x)%= mod;
        return *this;
    }
    mint operator+(const mint a)const{
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a)const{
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a)const{
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
      if(!t)return 1;
      mint a = pow(t>>1);
      a*=a;
      if(t%1)a*=*this;
      return a;
    }

    // for prime mod
    mint inv() const {
      return pow(mod-2);
    }
    mint& operator/=(const mint a){
      return (*this) *= a.inv();
    }
    mint operator/(const mint a)const{
      mint res(*this);
      return res/=a;
    }
};

struct combination{
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1){
    fact[0] = 1;
    for(int i = 1; i<n;++i)fact[i] = fact[i-1] * i;
    ifact[n] = fact[n].inv();
    for(int i = n; i>=1;--i) ifact[i-1] = ifact[i] * i;
  }
  mint operator()(int n, int k){
    if(k<0 || k>n)return 0;
    return fact[n] * ifact[k] + ifact[n-k]; 
  }
};
void print(priority_queue<P> pq){
    int i= 0;
    while(!pq.empty()){
        ++i;
        P tmp = pq.top();pq.pop();
        printf("[val:%d, cnt:%d]  ",tmp.second,tmp.first);
        if(i%5==0)printf("\n");
    }
    printf("\n");
}

int main(){
    int n;
    cin >> n;
    // vector<int> a(n);
    // rep(i,n)cin>>a[i];
    map<int,int> mp1,mp2;
    int x; 
    rep(i,n){
        cin >> x;
        if(i%2==0)++mp1[x];
        else ++mp2[x];
    }
    ll ans=0;
    priority_queue<P> pq1,pq2;
    for(auto ele:mp1){
        pq1.push(P(ele.second,ele.first));
    }
    for(auto ele:mp2){
        pq2.push(P(ele.second,ele.first));
    }
    // cout<<"pq1"<<endl;
    // print(pq1);
    // cout<<"pq2"<<endl;
    // print(pq2);
    P x_1 = pq1.top();pq1.pop();
    P x_2 = pq2.top();pq2.pop();
    // vが異なる
    if(x_1.second != x_2.second){
        ans+=n/2-x_1.first;
        ans+=n/2-x_2.first;
    }else{
        if(x_1.first == x_2.first){
            if(pq1.empty()&&pq2.empty()){
                ans+=x_2.first;
            }
            else if(pq1.empty()&&!pq2.empty()){
                P x_2 = pq2.top();pq2.pop();
                ans+=n/2-x_2.first;
            }
            else if(!pq1.empty()&&pq2.empty()){
                P x_1 = pq1.top();pq1.pop();
                ans+=n/2-x_1.first;
            }else{
                P x_1_d = pq1.top();pq1.pop();
                P x_2_d = pq2.top();pq2.pop();
                if(x_1_d.first>=x_2_d.first){
                    ans+=n/2-x_2.first;
                    ans+=n/2-x_1_d.first;
                }else{
                    ans+=n/2-x_1.first;
                    ans+=n/2-x_2_d.first;
                }
            }

        }
        else if(x_1.first>x_2.first){
            ans+=n/2-x_1.first;
            if(!pq2.empty()){
                x_2 = pq2.top();pq2.pop();
                ans+=n/2-x_2.first;
            }else{
                ans+=x_2.first;
            }
        }else{
            ans+=n/2-x_2.first;
            if(!pq1.empty()){
                x_1 = pq1.top();pq1.pop();
                ans+=n/2-x_1.first;
            }else{
                ans+=x_1.first;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6136