#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
int n;
int a[100000],b[100000];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    if(n==2) {
        cout<<0<<"\n";
        return 0;
    }
    int halfa, halfb;
        for(int i=0;i<n/2;i++) cin>>a[i]>>b[i];
        sort(a,a+n/2);
        sort(b,b+n/2);
        halfa=n/2;
        halfb=n/2;
    
    int counta=0;
    int maxa=0;
    int maxa2=0;
    int ma=-2;
    for(int i=0;i<halfa-1;i++){
        if(a[i]==a[i+1]) {
            counta++;
            if(i==halfa-2) {
                counta++;
                int temp=maxa;
                maxa=max(counta,maxa);
                if(maxa==counta) {
                    //maxa2=temp; 
                ma=a[i];
                }
            }
        }

        else{
            counta++;
            int temp=maxa;
            maxa=max(counta,maxa);
            if(maxa==counta) {
                   // maxa2=temp; 
                  ma=a[i];
               }
            counta=0;
        }
    }
    int countb=0;
    int maxb=0;
    int maxb2=0;
    int mb=-1;
    for(int i=0;i<halfb-1;i++){
        if(b[i]==b[i+1]) {
            countb++;
            if(i==halfb-2) {
                countb++;
                int temp=maxb;
                maxb=max(countb,maxb);
                if(maxb==countb) {
                //    maxb2=temp; 
                 mb=b[i];
               }
            }
        }
        else{
            countb++;
            int temp=maxb;
            maxb=max(countb,maxb);
            if(maxb==countb) {
                //maxb2=temp;
                mb=b[i];
            }
            countb=0;
        }
    }
    counta=0;
    countb=0;
    for(int i=0;i<halfa-1;i++){
        if(a[i]==ma)continue;
        if(a[i]==a[i+1]) {
            counta++;
            if(i==halfa-2) {
                counta++;
                int temp=maxa;
                maxa2=max(counta,maxa2);
                //if(maxa==counta) {
                    //maxa2=temp; 
                    //ma=a[i];
                //}
            }
        }

        else{
            counta++;
            int temp=maxa;
            maxa2=max(counta,maxa2);
            //if(maxa==counta) {
                   // maxa2=temp; 
                 // ma=a[i];
               // }
            counta=0;
        }
    }
    for(int i=0;i<halfb-1;i++){
        if(b[i]==mb)continue;
        if(b[i]==b[i+1]) {
            countb++;
            if(i==halfb-2) {
                countb++;
                int temp=maxb;
                maxb2=max(countb,maxb2);
                //if(maxb==countb) {
                //    maxb2=temp; 
                 //mb=b[i];
               // }
            }
        }
        else{
            countb++;
            int temp=maxb;
            maxb2=max(countb,maxb2);
            //if(maxb==countb) {
                //maxb2=temp;
                //mb=b[i];
            //}
            countb=0;
        }
    }
    int ans;
    if(ma==mb){
        ans=min(n-maxa-maxb2,n-maxa2-maxb);
    }
    else  ans=n-maxa-maxb;
    cout<<ans<<"\n";
}

Measured memory_bytes: 640