CodeEff/ECCO huggingface dataset:
# Original solution
N=int(eval(input()))
*V,=list(map(int,input().split()))
import collections

import collections

c1=collections.Counter(V[0::2])
c1=sorted(list(c1.items()), key=lambda x: x[1], reverse=True)
e=c1[0][0]

c2=collections.Counter(V[1::2])
c2=sorted(list(c2.items()), key=lambda x: x[1], reverse=True)
o=c2[0][0]

cnt=0
if e!=o:
    cnt=sum(e!=i for i in V[0::2])
    cnt+=sum(o!=i for i in V[1::2])
else:
    if len(c1)==1 and len(c2)==1:
        cnt=N//2
    elif len(c1)==1:
        cnt1=sum(e!=i for i in V[0::2])
        cnt1+=sum(c2[1][0]!=i for i in V[1::2])
        
        cnt2=sum(e!=i for i in V[0::2])
        cnt2+=sum(c2[1][1]!=i for i in V[1::2])
        cnt=min(cnt1,cnt2)
    elif len(c2)==1:
        cnt1=sum(c1[1][0]!=i for i in V[0::2])
        cnt1+=sum(o!=i for i in V[1::2])

        cnt2=sum(c1[1][1]!=i for i in V[0::2])
        cnt2+=sum(o!=i for i in V[1::2])
        cnt=min(cnt1,cnt2)
    else:    
        cnt1=sum(e!=i for i in V[0::2])
        cnt1+=sum(c2[1][0]!=i for i in V[1::2])
        
        cnt2=sum(c1[1][0]!=i for i in V[0::2])
        cnt2+=sum(o!=i for i in V[1::2])
        cnt=min(cnt1,cnt2)
print(cnt)

# Optimized solution
N=int(eval(input()))
*V,=list(map(int,input().split()))
import collections

c1=collections.Counter(V[0::2]).most_common()
c2=collections.Counter(V[1::2]).most_common()
c1.append([0,0])
c2.append([0,0])
if c1[0][0]!=c2[0][0]:
    print((N-c1[0][1]-c2[0][1]))
else:
    print((min(N-c1[0][1]-c2[1][1],N-c1[1][1]-c2[0][1])))
# Original solution
import sys
from collections import Counter

readline = sys.stdin.readline
readlines = sys.stdin.readlines
ns = lambda: readline().rstrip() # input string
ni = lambda: int(readline().rstrip()) # input int
nm = lambda: list(map(int, readline().split())) # input multiple int 
nl = lambda: list(map(int, readline().split())) # input multiple int to list

n = ni()
v = nl()
odd = Counter(v[0::2])
even = Counter(v[1::2])
odd["$"] = 0
even["#"] = 0
ans = 0
if odd.most_common()[0][0] == even.most_common()[0][0]:
    if odd.most_common()[1][1] > even.most_common()[1][1]:
        ans = n - odd.most_common()[1][1] - even.most_common()[0][1]
    else:
        ans = n - odd.most_common()[0][1] - even.most_common()[1][1]
else:
    ans = n - odd.most_common()[0][1] - even.most_common()[0][1]
"""if len(odd) == 1:
    pass
else:
    for v in odd.values():
        max_odd = max(max_odd, v)
    ans += len(odd) - max_odd

if len(even) == 1:
    pass
else:
    for v in even.values():
        max_even = max(max_even, v)
    ans += len(even) - max_even"""

print(ans)

# Optimized solution
from collections import Counter

n = int(eval(input()))
v = list(map(int, input().split()))
odd = Counter(v[0::2])
even = Counter(v[1::2])
odd["$"] = 0
even["#"] = 0
ans = 0
if odd.most_common()[0][0] == even.most_common()[0][0]:
    if odd.most_common()[1][1] > even.most_common()[1][1]:
        ans = n - odd.most_common()[1][1] - even.most_common()[0][1]
    else:
        ans = n - odd.most_common()[0][1] - even.most_common()[1][1]
else:
    ans = n - odd.most_common()[0][1] - even.most_common()[0][1]
print(ans)
# Original solution
import collections


def main():
    n = int(eval(input()))
    *v, = list(map(int, input().split()))

    v0 = count(v[::2])
    v1 = count(v[1::2])

    if len(v0) == 1 and len(v1) == 1:
        if v0[0][0] == v1[0][0]:
            print((n // 2))
        else:
            print((0))
        return

    l0 = max(2, len(v0))
    l1 = max(2, len(v1))

    INF = 10 ** 9
    score = [[0] * l1 for _ in range(l0)]
    for i in range(l0):
        for j in range(l1):
            score[i][j] = sum_v(v0, i) + sum_v(v1, j)
            if i >= l0 - 1 or j >= l1 - 1 or v0[i][0] == v1[j][0]:
                score[i][j] = INF
    print((min([min(s) for s in score])))


def count(v):
    return collections.Counter(v).most_common()


def sum_v(v, ii):
    return sum([vv[1] for i, vv in enumerate(v) if i != ii])


main()


# Optimized solution
import collections


def main():
    n = int(eval(input()))
    *v, = list(map(int, input().split()))

    v0 = count(v[::2])
    v1 = count(v[1::2])

    if len(v0) == 1 and len(v1) == 1:
        if v0[0][0] == v1[0][0]:
            print((n // 2))
        else:
            print((0))
        return

    l0 = min(2, len(v0))
    l1 = min(2, len(v1))

    INF = 10 ** 9
    score = [[0] * l1 for _ in range(l0)]
    for i in range(l0):
        for j in range(l1):
            score[i][j] = sum_v(v0, i) + sum_v(v1, j)
            if i >= l0 or j >= l1 or v0[i][0] == v1[j][0]:
                score[i][j] = INF
    print((min([min(s) for s in score])))


def count(v):
    return collections.Counter(v).most_common()


def sum_v(v, ii):
    return sum([vv[1] for i, vv in enumerate(v) if i != ii])


main()
# Original solution
import math,fractions
from collections import Counter
n = int(eval(input()))
v = [int(i) for i in input().split()]
a = [v[i] for i in range(n) if i%2]
b = [v[i] for i in range(n) if i%2==0]
cnt_a = Counter(a)
cnt_b = Counter(b)
max_a = cnt_a.most_common()[0][1]
max_b = cnt_b.most_common()[0][1]

str_a = cnt_a.most_common()[0][0]
str_b = cnt_b.most_common()[0][0]

max_2a = 0
max_2b = 0

for i in cnt_a:
    if str_a != i  and cnt_a[i] > max_2a:
        max_2a = cnt_a[i]

for i in cnt_b:
    if str_b != i  and cnt_b[i] > max_2b:
        max_2b = cnt_b[i]

if str_a != str_b:
    print((n//2 - max_a + n//2 - max_b))
else:
    tmp_a = n//2 - max_2a + n//2 - max_b
    tmp_b = n//2 - max_a + n//2 - max_2b
    print((min(tmp_a,tmp_b)))

# Optimized solution
import math,fractions
from collections import Counter
n = int(eval(input()))
v = [int(i) for i in input().split()]
a = Counter(v[1::2]).most_common()
b = Counter(v[0::2]).most_common()
a.append((0,0))
b.append((0,0))

if a[0][0] != b[0][0]:
    print((n//2 - a[0][1] + n//2 - b[0][1]))
else:
    tmp_x = n//2 - a[1][1] + n//2 - b[0][1]
    tmp_y = n//2 - a[0][1] + n//2 - b[1][1]
    print((min(tmp_x, tmp_y)))
# Original solution
import collections as coll

n = int(eval(input()))
v = list(map(int,input().split()))
even = []
odd = []

for i in range(n):
	if i % 2 == 0:
		even.append(v[i])
	else:
		odd.append(v[i])

oddc = coll.Counter(odd).most_common()[:2]
evenc = coll.Counter(even).most_common()[:2]

if(len(oddc) == 1):
	oddc.append((0,0))
if(len(evenc) == 1):
	evenc.append((0,0))


if(oddc[0][0] != evenc[0][0]):
	print((n - oddc[0][1] - evenc[0][1]))
else:
	print((min(n-oddc[0][1]-evenc[1][1],n-oddc[1][1]-evenc[0][1])))

# Optimized solution
import collections as coll

n = int(eval(input()))
v = list(map(int,input().split()))
even = v[0::2]
odd = v[1::2]

oddc = coll.Counter(odd).most_common()[:2]
evenc = coll.Counter(even).most_common()[:2]

if(len(oddc) == 1):
	oddc.append((0,0))
if(len(evenc) == 1):
	evenc.append((0,0))


if(oddc[0][0] != evenc[0][0]):
	print((n - oddc[0][1] - evenc[0][1]))
else:
	print((min(n-oddc[0][1]-evenc[1][1],n-oddc[1][1]-evenc[0][1])))
# Original solution
import itertools
from collections import Counter

N = int(eval(input()))
V = [int(x) for x in input().split()]
EV_counter = Counter(V[::2])
OD_counter = Counter(V[1::2])

# 1種類しかないとき対策
EV_counter[-1] = 0
OD_counter[-2] = 0

# 上位2種しか使う必要がない
EV = EV_counter.most_common(2)
OD = OD_counter.most_common(2)

answer = N
for (k1,v1), (k2,v2) in itertools.product(EV,OD):
  if k1 == k2:
    continue
  x = (N - v1 - v2)
  if answer > x:
    answer = x

print(answer)


# Optimized solution
from collections import Counter
n=int(eval(input()))
v=list(map(int,input().split()))
a=Counter(v[0::2]).most_common()
b=Counter(v[1::2]).most_common()
a.append([0,0])
b.append([0,0])
if a[0][0]!=b[0][0]:
    print((n-(a[0][1]+b[0][1])))
else:
    print((min(n-(a[1][1]+b[0][1]),n-(a[0][1]+b[1][1]))))
# Original solution
# -*- coding: utf-8 -*-
from collections import defaultdict
from operator import itemgetter
def solve():
    n = int(eval(input()))
    V = list(map(int, input().split()))
    l = defaultdict(int)
    u = defaultdict(int)
    for i in range(0,n,2):
        l[V[i]] += 1
        u[V[i+1]] += 1

    l = sorted(list(l.items()),key=itemgetter(1))[::-1]
    u = sorted(list(u.items()),key=itemgetter(1))[::-1]
    if len(l) == len(u) == 1:
        if l[0][0] != u[0][0]:
            res = 0
        else:
            res = min(l[0][1], u[0][1])
    else:
        if l[0][0] != u[0][0]:
            res = sum(map(itemgetter(1), l[1:])) + sum(map(itemgetter(1), u[1:]))
        elif len(u) == 1 or (len(l) > 1 and l[1][1]+u[0][1] > l[0][1]+u[1][1]):
            res = l[0][1] + sum(map(itemgetter(1), l[2:])) + sum(map(itemgetter(1), u[1:]))
        else:
            res = u[0][1] + sum(map(itemgetter(1), l[1:])) + sum(map(itemgetter(1), u[2:]))

    return str(res)

if __name__ == '__main__':
    print((solve()))



# Optimized solution
# -*- coding: utf-8 -*-
from collections import Counter
from operator import itemgetter
def solve():
    eval(input())
    V = list(map(int, input().split()))
    l = sorted(list(Counter(V[::2]).items())+[(0,0)], key=itemgetter(1), reverse=True)
    u = sorted(list(Counter(V[1::2]).items())+[(0,0)], key=itemgetter(1), reverse=True)
    res = sum(map(itemgetter(1), l+u)) - (max(l[0][1]+u[1][1], l[1][1]+u[0][1]) if l[0][0]==u[0][0] else (l[0][1]+u[0][1]))
    return str(res)

if __name__ == '__main__':
    print((solve()))
# Original solution
import itertools
import math
import fractions
import functools
import copy

n = int(eval(input()))
v = list(map(int, input().split()))

kisu = [0]*(10**6)
gusu = [0]*(10**6)
for i in range(n):
    if i % 2 == 0:
        gusu[v[i]] += 1
    else:
        kisu[v[i]] += 1

count = 0
gusu_m = gusu.index(max(gusu))
kisu_m = kisu.index(max(kisu))

if gusu_m == kisu_m:

    gusu[gusu_m] = 0
    kisu[kisu_m] = 0
    if max(gusu) > max(kisu):
        gusu_m = gusu.index(max(gusu))
    else:
        kisu_m = kisu.index(max(kisu))

for i in range(n):
    if i % 2 == 0 and gusu_m != v[i]:
        count += 1
    if i % 2 != 0 and kisu_m != v[i]:
        count += 1

print(count)


# Optimized solution

n = int(eval(input()))
v = list(map(int, input().split()))

kisu = [0]*(10**6)
gusu = [0]*(10**6)
for i in range(n):
    if i % 2 == 0:
        gusu[v[i]] += 1
    else:
        kisu[v[i]] += 1

count = 0
gusu_m = gusu.index(max(gusu))
kisu_m = kisu.index(max(kisu))

if gusu_m == kisu_m:

    gusu[gusu_m] = 0
    kisu[kisu_m] = 0
    if max(gusu) > max(kisu):
        gusu_m = gusu.index(max(gusu))
    else:
        kisu_m = kisu.index(max(kisu))

for i in range(n):
    if i % 2 == 0 and gusu_m != v[i]:
        count += 1
    if i % 2 != 0 and kisu_m != v[i]:
        count += 1

print(count)
# Original solution

n = int(eval(input()))
v = list(map(int, input().split()))

kisu = [0]*(10**6)
gusu = [0]*(10**6)
for i in range(n):
    if i % 2 == 0:
        gusu[v[i]] += 1
    else:
        kisu[v[i]] += 1

count = 0
gusu_m = gusu.index(max(gusu))
kisu_m = kisu.index(max(kisu))

if gusu_m == kisu_m:

    gusu[gusu_m] = 0
    kisu[kisu_m] = 0
    if max(gusu) > max(kisu):
        gusu_m = gusu.index(max(gusu))
    else:
        kisu_m = kisu.index(max(kisu))

for i in range(n):
    if i % 2 == 0 and gusu_m != v[i]:
        count += 1
    if i % 2 != 0 and kisu_m != v[i]:
        count += 1

print(count)


# Optimized solution
def main():
    n = int(eval(input()))
    # n, k = map(int, input().split())
    v = list(map(int, input().split()))
    # s = input()

    even = [0] * (10 ** 5 + 100)
    odd = [0] * (10 ** 5 + 100)

    for i in range(n):
        if i % 2 == 0:
            even[v[i]] += 1
        else:
            odd[v[i]] += 1

    max_even = even.index(max(even))
    max_odd = odd.index(max(odd))

    if max_even == max_odd:
        even[max_even] = 0
        odd[max_odd] = 0
        if max(even) < max(odd):
            max_odd = odd.index(max(odd))
        else:
            max_even = even.index(max(even))
    ans = 0
    for i in range(n):
        if i % 2 == 0 and max_even != v[i]:
            ans += 1
        if i % 2 != 0 and max_odd != v[i]:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()
# Original solution
from collections import Counter
import heapq

N = int(eval(input()))
Vs = list(map(int,input().split()))

if len(set(Vs)) == 1:
  print((N//2))
  exit()

Veve, Vodd = [],[]
idx = 0
for v in Vs:
  if idx%2 == 0: Veve.append(v)
  else: Vodd.append(v)
  idx += 1

Veve_cnt, Vodd_cnt = [], []
[heapq.heappush(Veve_cnt, [-num,val]) for val, num in list(Counter(Veve).items())]
[heapq.heappush(Vodd_cnt, [-num,val]) for val, num in list(Counter(Vodd).items())]

neg_num, val = heapq.heappop(Veve_cnt)
eve_val = val
eve_num = -neg_num

neg_num, val = heapq.heappop(Vodd_cnt)
odd_val = val
odd_num = -neg_num

if eve_val != odd_val:
  print((N-eve_num-odd_num))
else:
  if len(Vodd_cnt) != 0:odd_num2 = -heapq.heappop(Vodd_cnt)[0]
  else:odd_num2 = -float('inf')

  if len(Veve_cnt) != 0:eve_num2 = -heapq.heappop(Veve_cnt)[0]
  else:eve_num2 = -float('inf')

  print((min(N-eve_num2-odd_num,N-eve_num-odd_num2)))

# Optimized solution
N = int(eval(input()))
V = list(map(int, input().split()))

even_idx_cnt = {}
odd_idx_cnt = {}
for idx, v in enumerate(V):
    if idx % 2 == 0:
        if v not in even_idx_cnt:
            even_idx_cnt[v] = 0
        even_idx_cnt[v] += 1
    else:
        if v not in odd_idx_cnt:
            odd_idx_cnt[v] = 0
        odd_idx_cnt[v] += 1

if len(even_idx_cnt) == 1 and len(odd_idx_cnt) == 1:
    if list(even_idx_cnt.keys()) == list(odd_idx_cnt.keys()):
        print((N - even_idx_cnt[V[0]]))
    else:
        print((0))
    exit()

even_idx_cnt = sorted(list(even_idx_cnt.items()), key=lambda  x:x[1], reverse=True)
odd_idx_cnt = sorted(list(odd_idx_cnt.items()), key=lambda  x:x[1], reverse=True)

if even_idx_cnt[0][0] != odd_idx_cnt[0][0]:
    print((N - even_idx_cnt[0][1] - odd_idx_cnt[0][1]))
else:
    ans = []
    if len(odd_idx_cnt) >= 2:
        ans.append(N - even_idx_cnt[0][1] - odd_idx_cnt[1][1])
    if len(even_idx_cnt) >= 2:
        ans.append(N - even_idx_cnt[1][1] - odd_idx_cnt[0][1])
    print((min(ans)))
# Original solution
N = int(eval(input()))
V = list(map(int,input().split()))

from collections import Counter

def get_counter(X):
  counter = Counter(X)
  X = sorted(list(counter.items()), key = lambda x:x[1], reverse = True)
  X.append((0,0))
  return X

V1 = get_counter(V[::2])
V2 = get_counter(V[1::2])

if V1[0][0] != V2[0][0]:
  print((N - (V1[0][1] + V2[0][1])))
else:
  print((N - max(V1[0][1] + V2[1][1],V1[1][1] + V2[0][1])))


# Optimized solution
N = int(eval(input()))
V = list(map(int,input().split()))

from collections import Counter

def get_counter(X):
  counter = Counter(X)
  X = counter.most_common()
  X.append((0,0))
  return X

V1 = get_counter(V[::2])
V2 = get_counter(V[1::2])

if V1[0][0] != V2[0][0]:
  print((N - (V1[0][1] + V2[0][1])))
else:
  print((N - max(V1[0][1] + V2[1][1],V1[1][1] + V2[0][1])))
# Original solution
from collections import*
n,*v=list(map(int,open(0).read().split()))
a,b=[Counter(i).most_common()+[(0,0)]for i in(v[::2],v[1::2])]
i,j=a[0][1],b[0][1]
print((min(n-i-b[1][1],n-a[1][1]-j)*(a[0][0]==b[0][0])or n-i-j))

# Optimized solution
from collections import*;n,*v=list(map(int,open(0).read().split()));a,b=[Counter(v[i::2]).most_common()+[(0,0)]for i in(0,1)];i,x=a[0];j,y=b[0];print((n-[x+y,max(x+b[1][1],y+a[1][1])][i==j]))
# Original solution
import collections
import itertools
n = int(eval(input()))
v = list(map(int,input().split()))
#n = len(v)
c = collections.Counter(v).most_common()
if len(c) == 1:
    print((n//2))
    exit()
values, counts = list(zip(*c))
k = sorted(list(set(counts)),reverse=True)[:2]
pairs = []
for vcnt in c:
    val = vcnt[0]
    cnt = vcnt[1]
    #print(val,cnt)
    if cnt in k:
        pairs.append(val)
#print(pairs)
P = list(itertools.combinations(pairs,2))
#print(P)
ans = float('inf')
for pair in P:
    #print(pair)
    mc = pair[0]
    sc = pair[1]
    tmp = 0
    for i in range(n):
        if i % 2 == 0 and v[i] != mc:
            tmp += 1
        elif i % 2 == 1 and v[i] != sc:
            tmp += 1
    ttmp = 0
    for i in range(n):
        if i % 2 == 0 and v[i] != sc:
            ttmp += 1
        elif i % 2 == 1 and v[i] != mc:
            ttmp += 1

    ans = min(ans,min(tmp,ttmp))
    
print(ans)

# Optimized solution
from collections import Counter
n = int(eval(input()))
v = list(map(int,input().split()))
o = Counter(v[::2]).most_common()
o.append((0,0))
e = Counter(v[1::2]).most_common()
e.append((0,0))
if o[0][0] == e[0][0]:
    ans = min(n - o[0][1] - e[1][1], n - o[1][1] - e[0][1])
else:
    ans = n - o[0][1] - e[0][1]
print(ans)
# Original solution
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return list(map(int, sys.stdin.readline().split()))
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

N = ii()
A = li()

d_o = defaultdict(int)
d_e = defaultdict(int)

for i in range(N):
    if i % 2:
        d_o[A[i]] += 1
    else:
        d_e[A[i]] += 1

l_d = sorted(list(d_o.items()), key=lambda x:x[1], reverse=True)
l_e = sorted(list(d_e.items()), key=lambda x:x[1], reverse=True)

if l_d[0][0] != l_e[0][0]:
    print((N - l_d[0][1] - l_e[0][1]))
elif len(l_d) == len(l_e) == 1:
        print((N - max(l_d[0][1], l_e[0][1])))
elif len(l_d) == 1:
        ans = min(N - l_d[0][1] - l_e[1][1], N - l_e[0][1])
        print(ans)
elif len(l_e) == 1:
        ans = min(N - l_d[1][1] - l_e[0][1], N - l_d[0][1])
        print(ans)
else:
    ans = min(N-l_d[1][1]-l_e[0][1], N-l_d[0][1]-l_e[1][1])
    print(ans)

# Optimized solution
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return list(map(int, sys.stdin.readline().split()))
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

N = ii()
A = li()

d_o = defaultdict(int)
d_e = defaultdict(int)

for i in range(N):
    if i % 2:
        d_o[A[i]] += 1
    else:
        d_e[A[i]] += 1

l_d = sorted(list(d_o.items()), key=lambda x:x[1], reverse=True)
l_e = sorted(list(d_e.items()), key=lambda x:x[1], reverse=True)

if l_d[0][0] != l_e[0][0]:
    print((N - l_d[0][1] - l_e[0][1]))
elif len(l_d) == len(l_e) == 1:
        print((N - max(l_d[0][1], l_e[0][1])))
elif len(l_d) == 1:
        #ans = min(N - l_d[0][1] - l_e[1][1], N - l_e[0][1])
        #print(ans)
        print((N - l_d[0][1] - l_e[1][1]))
elif len(l_e) == 1:
        #ans = min(N - l_d[1][1] - l_e[0][1], N - l_d[0][1])
        #print(ans)
        print((N - l_d[1][1] - l_e[0][1]))
else:
    ans = min(N-l_d[1][1]-l_e[0][1], N-l_d[0][1]-l_e[1][1])
    print(ans)
# Original solution
from collections import Counter
n = int(eval(input()))
V = list(map(int,input().split()))
E = []
O = []
for i,v in enumerate(V):
    if i%2==0:
        O.append(v)
    else:
        E.append(v)

cO = Counter(O).most_common(); cO.append((-1,0))
cE = Counter(E).most_common(); cE.append((-1,0))
if cO[0][0]==cE[0][0]: 
    ans = min(n-cO[0][1]-cE[1][1], n-cO[1][1]-cE[0][1])
else:
    ans = n-cO[0][1]-cE[0][1]
print(ans)

# Optimized solution
from collections import Counter
n = int(eval(input()))
V = list(map(int,input().split()))
cv1 = Counter(V[::2]).most_common()
cv2 = Counter(V[1::2]).most_common()
cv1.append((-1,0)); cv2.append((-1,0))
if cv1[0][0] != cv2[0][0]:
    print((n-cv1[0][1]-cv2[0][1]))
else:
    print((min(n-cv1[1][1]-cv2[0][1], n-cv1[0][1]-cv2[1][1])))
# Original solution
from collections import Counter
N = int(eval(input()))
V = list(map(int,input().split()))

c1 = Counter(V[::2])
c2 = Counter(V[1::2])
m1 = c1.most_common()
m2 = c2.most_common()
t2 = N//2
t1 = N - t2

if len(m1) == len(m2) == 1:
    print((N//2 if m1[0][0] == m2[0][0] else 0))
elif len(m1) == 1:
    if m1[0][0] != m2[0][0]:
        print((t1 - m2[0][1]))
    else:
        print((t1 - m2[1][1]))
elif len(m2) == 1:
    if m1[0][0] != m2[0][0]:
        print((t2 - m1[0][1]))
    else:
        print((t2 - m1[1][1]))
else:
    if m1[0][0] != m2[0][0]:
        print((N - m1[0][1] - m2[0][1]))
    else:
        ans = N - m1[1][1] - m2[1][1]
        if m1[0][0] != m2[1][0]:
            ans = min(ans, N - m1[0][1] - m2[1][1])
        if m1[1][0] != m2[0][0]:
            ans = min(ans, N - m1[1][1] - m2[0][1])
        print(ans)

# Optimized solution
from collections import Counter
N = int(eval(input()))
V = list(map(int,input().split()))
c1 = Counter(V[::2])
c2 = Counter(V[1::2])
n1 = N//2 + N%2
n2 = N//2

if len(c1)==1 and len(c2)==1:
    if V[0]==V[1]:
        print(n2)
    else:
        print((0))
elif len(c1)==1:
    mc = c2.most_common()
    if mc[0][0] == V[0]:
        print((n2 - mc[1][1]))
    else:
        print((n2 - mc[0][1]))
elif len(c2)==1:
    mc = c1.most_common()
    if mc[0][0] == V[1]:
        print((n1 - mc[1][1]))
    else:
        print((n1 - mc[0][1]))
else:
    mc1 = c1.most_common()
    mc2 = c2.most_common()
    if mc1[0][0] != mc2[0][0]:
        print((N - mc1[0][1] - mc2[0][1]))
    else:
        ans = N
        if mc1[0][0] != mc2[1][0]:
            ans = min(ans, N - mc1[0][1] - mc2[1][1])
        if mc1[1][0] != mc2[0][0]:
            ans = min(ans, N - mc1[1][1] - mc2[0][1])
        print(ans)
# Original solution
import collections

n = int(eval(input()))
v = list(map(int, input().split()))
a = v[::2]
b = v[1::2]
ac = collections.Counter(a)
bc = collections.Counter(b)
ac = sorted(list(ac.items()), key=lambda x: x[1], reverse=True)
bc = sorted(list(bc.items()), key=lambda x: x[1], reverse=True)
if ac[0][0] == bc[0][0]:
    if len(ac) == len(bc) and len(ac) == 1:
        print((ac[0][1]))
        exit()
    i = 0
    while ac[i][1] == bc[i][1]:
        i += 1
        if i == len(ac) - 1 or i == len(bc) - 1:
            break
    if ac[i][1] > bc[i][1]:
        ac.remove(ac[i])
        bc.remove(bc[0])
    elif ac[i][1] < bc[i][1]:
        ac.remove(ac[0])
        bc.remove(bc[i])
    else:
        ac.remove(ac[0])
        bc.remove(bc[1])
else:
    ac.remove(ac[0])
    bc.remove(bc[0])
ans = 0
for i in range(len(ac)):
    ans += ac[i][1]
for i in range(len(bc)):
    ans += bc[i][1]
print(ans)


# Optimized solution
import collections

n = int(eval(input()))
v = list(map(int, input().split()))
a = v[::2]
b = v[1::2]
ac = collections.Counter(a).most_common(2)
bc = collections.Counter(b).most_common(2)
if ac[0][0] != bc[0][0]:
    print((n - ac[0][1] - bc[0][1]))
else:
    if len(ac) == 1:
        print((n // 2))
    else:
        print((n - max(ac[0][1] + bc[1][1], ac[1][1] + bc[0][1])))