CodeEff/ECCO huggingface dataset:
# Original solution
import collections
N = int(eval(input()))
v = list(map(int, input().split()))
if len(set(v)) == 1:
  print((int(len(v)/2)))
  exit()
ov = [v[i] for i in range(1,len(v),2)]
ev = [v[i] for i in range(0, len(v), 2)]

cov = collections.Counter(ov)
cev = collections.Counter(ev)
mov = cov.most_common()[0][0]
mev = cev.most_common()[0][0]
ans = len(v) - cov[mov] - cev[mev]

if mov == mev:
  ans1 = len(v) - cov.most_common()[1][1] - cev.most_common()[0][1]
  ans2 = len(v) - cov.most_common()[0][1] - cev.most_common()[1][1]
  ans = min(ans1, ans2)

print(ans)

# Optimized solution
import collections
N = int(eval(input()))
v = list(map(int, input().split()))
if len(set(v)) == 1:
  print((int(len(v)/2)))
  exit()
cov = collections.Counter(v[1::2])
cev = collections.Counter(v[::2])
mov = cov.most_common()[0][0]
mev = cev.most_common()[0][0]
ans = len(v) - cov[mov] - cev[mev]

if mov == mev:
  ans1 = len(v) - cov.most_common()[1][1] - cev.most_common()[0][1]
  ans2 = len(v) - cov.most_common()[0][1] - cev.most_common()[1][1]
  ans = min(ans1, ans2)

print(ans)
# Original solution
from collections import Counter
from collections import deque

if __name__ == '__main__':
    n = int(eval(input()))
    vs0 = []
    vs1 = []
    for i,v in enumerate(map(int, input().split())):
        if i % 2 == 0:
            vs0.append(v)
        else:
            vs1.append(v)
    vs0 = deque(sorted(list(Counter(vs0).items()), key=lambda t: t[1]))
    vs1 = deque(sorted(list(Counter(vs1).items()), key=lambda t: t[1]))
    t0 = vs0.pop()
    t1 = vs1.pop()
    if t0[0] != t1[0]:
        vs0 = (t[1] for t in vs0)
        vs1 = (t[1] for t in vs1)
        print((sum(vs0) + sum(vs1)))
    else:
        if len(vs1) == 0:
            if len(vs0) == 0:
                print((t1[1]))
            else:
                vs0 = (t[1] for t in vs0)
                print((sum(vs0)))
        elif len(vs0) == 0:
            vs1 = (t[1] for t in vs1)
            print((sum(vs1)))
        else:
            t00 = vs0.pop()
            t11 = vs1.pop()
            a = t00[1] + t1[1]
            b = t11[1] + t0[1]
            vs0 = (t[1] for t in vs0)
            vs1 = (t[1] for t in vs1)
            print((sum(vs0) + sum(vs1) + (a if a < b else b)))




# Optimized solution
from collections import Counter

if __name__ == '__main__':
    n = int(eval(input()))
    vs = [int(s) for s in input().split()]
    counter0 = list(Counter(vs[0::2]).items()) + [(100001, 0)]
    counter1 = list(Counter(vs[1::2]).items()) + [(100001, 0)]
    v0, c0 = max(counter0, key=lambda t: t[1])
    v1, c1 = max(counter1, key=lambda t: t[1])
    counter0.remove((v0, c0))
    counter1.remove((v1, c1))
    res = 0
    if v0 != v1:
        res = n - c0 - c1
    else:
        _, c02 = max(counter0, key=lambda t: t[1])
        _, c12 = max(counter1, key=lambda t: t[1])
        res = n - (c0 + c12 if c12 > c02 else c1 + c02)
    print(res)
# Original solution
n = int(eval(input()))
V = list(map(int,input().split()))
a = [0]*10000000
b = [0]*10000000
v1=[]
v2=[]

if len(set(V)) == 1:
    print((n//2))

else:
    for i in range(n):
        if i%2 == 0:
            a[V[i]-1] += 1
            v1.append(V[i])
        else:
            b[V[i]-1] += 1
            v2.append(V[i])

    max1 = 0
    max2 = 0

    for j in range(len(a)):
        if max1 < a[j]:
            max1 = a[j]
            c1 = j
    for k in range(len(b)):
        if max2 < b[k]:
            max2=b[k]
            c2=k

    if c1 != c2:
        print((n-max1-max2))
    else:
        a.sort()
        b.sort()
        print((min(n-max1-b[-2],n-max2-a[-2])))


# Optimized solution
n = int(eval(input()))
V = list(map(int,input().split()))
a = [0]*100000
b = [0]*100000
v1=[]
v2=[]

if len(set(V)) == 1:
    print((n//2))

else:
    for i in range(n):
        if i%2 == 0:
            a[V[i]-1] += 1
            v1.append(V[i])
        else:
            b[V[i]-1] += 1
            v2.append(V[i])

    max1 = 0
    max2 = 0

    for j in range(len(a)):
        if max1 < a[j]:
            max1 = a[j]
            c1 = j
    for k in range(len(b)):
        if max2 < b[k]:
            max2=b[k]
            c2=k

    if c1 != c2:
        print((n-max1-max2))
    else:
        a.sort()
        b.sort()
        print((min(n-max1-b[-2],n-max2-a[-2])))
# Original solution
n = int(eval(input()))
V = list(map(int,input().split()))
a = [0]*100000
b = [0]*100000
v1=[]
v2=[]

if len(set(V)) == 1:
    print((n//2))

else:
    for i in range(n):
        if i%2 == 0:
            a[V[i]-1] += 1
            v1.append(V[i])
        else:
            b[V[i]-1] += 1
            v2.append(V[i])

    max1 = 0
    max2 = 0

    for j in range(len(a)):
        if max1 < a[j]:
            max1 = a[j]
            c1 = j
    for k in range(len(b)):
        if max2 < b[k]:
            max2=b[k]
            c2=k

    if c1 != c2:
        print((n-max1-max2))
    else:
        a.sort()
        b.sort()
        print((min(n-max1-b[-2],n-max2-a[-2])))


# Optimized solution
from collections import Counter
N = int(eval(input()))
V = list(map(int,input().split()))
zero = Counter(V[::2]).most_common()
one = Counter(V[1::2]).most_common()
if zero[0][0] != one[0][0]:
    print((N-zero[0][1]-one[0][1]))
else:
    if len(zero) == 1 and len(one) == 1:
        print((N//2))
    elif len(zero) == 1:
        print((N-zero[0][1]-one[1][1]))
    elif len(one) == 1:
        print((N-zero[1][1]-one[0][1]))
    else:
        print((min(N-zero[1][1]-one[0][1],N-zero[0][1]-one[1][1])))
# Original solution
import collections

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

v_odd = []
v_even = []

for i, v in enumerate(v):
    if i % 2:
        v_even.append(v)
    else:
        v_odd.append(v)

# Counterに入れて、valueの降順にソート
v_odd_c = collections.Counter(v_odd)
v_odd_c = sorted(list(v_odd_c.items()), key=lambda x: x[1], reverse=True)
v_even_c = collections.Counter(v_even)
v_even_c = sorted(list(v_even_c.items()), key=lambda x: x[1], reverse=True)

# counterに一つしかkeyがないと面倒なので0が0回出たことを明示的に示しておく
# 制約上、0はvとしてあり得ないので問題ない（必ず0は0回出る）
v_odd_c.append([0, 0])
v_even_c.append([0, 0])

# print(v_odd_c)
# print(v_even_c)

if n != 2:
    o1 = v_odd_c[0]
    o2 = v_odd_c[1]
    e1 = v_even_c[0]
    e2 = v_even_c[1]

    # 最頻値が異なる場合
    if o1[0] != e1[0]:
        ans = n - o1[1] - e1[1]
    # 最頻値が等しい場合
    elif o1[0] == e1[0]:
        # o1,e2を採用する場合
        temp1 = n - o1[1] - e2[1]
        #o2, e1を採用する場合
        temp2 = n - o2[1] - e1[1]
        ans = min(temp1, temp2)

elif n == 2:
    if v_odd_c[0][1] != v_even_c[0][1]:
        ans = 0
    else:
        ans = 1

print(ans)


# Optimized solution
import collections

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

v_odd = []
v_even = []

for i, v in enumerate(v):
    if i % 2:
        v_even.append(v)
    else:
        v_odd.append(v)

# Counterに入れて、valueの降順にソート
v_odd_c = collections.Counter(v_odd)
v_odd_c = sorted(list(v_odd_c.items()), key=lambda x: x[1], reverse=True)
v_even_c = collections.Counter(v_even)
v_even_c = sorted(list(v_even_c.items()), key=lambda x: x[1], reverse=True)

# counterに一つしかkeyがないと面倒なので0が0回出たことを明示的に示しておく
# 制約上、0はvとしてあり得ないので問題ない（必ず0は0回出る）
v_odd_c.append([0, 0])
v_even_c.append([0, 0])

if n != 2:
    o1 = v_odd_c[0]
    o2 = v_odd_c[1]
    e1 = v_even_c[0]
    e2 = v_even_c[1]

    # 最頻値が異なる場合
    if o1[0] != e1[0]:
        ans = n - o1[1] - e1[1]
    # 最頻値が等しい場合
    elif o1[0] == e1[0]:
        # o1,e2を採用する場合
        temp1 = n - o1[1] - e2[1]
        #o2, e1を採用する場合
        temp2 = n - o2[1] - e1[1]
        ans = min(temp1, temp2)

print(ans)
# Original solution
from collections import Counter
N = int(eval(input()))
a = list(map(int,input().split()))
even = [[0,0]] + sorted([v,k] for k,v in list(Counter(a[1::2]).items()))
odd = [[0,0]] + sorted([v,k] for k,v in list(Counter(a[0::2]).items()))

if even[-1][1] != odd[-1][1]:
    print((N - even[-1][0] - odd[-1][0]))
else:
    print((min(N - even[-1][0] - odd[-2][0], N - even[-2][0] - odd[-1][0])))


# Optimized solution
from collections import Counter
n = int(eval(input()))
v = list(map(int, 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]
aa = Counter(a)
bb = Counter(b)
ans = 0

aas = sorted(list(aa.keys()), key=lambda key:aa[key], reverse=True)
bbs = sorted(list(bb.keys()), key=lambda key:bb[key], reverse=True)
if aas[0] != bbs[0]:
    ans += len(a) - aa[aas[0]]
    ans += len(b) - bb[bbs[0]]
else:
    if len(aa) == len(bb) and len(aa) == 1 and a[0] == b[0]:
        ans += min(len(a), len(b))
    else:
        s = len(a) - aa[aas[0]] + len(b) - bb[bbs[1]]
        t = len(a) - aa[aas[1]] + len(b) - bb[bbs[0]]
        ans = min(s,t)

print(ans)
# Original solution
import collections
def main():
    n = int(eval(input()))
    v = list(map(int,input().split()))

    if len(set(v)) == 1:
        print((n//2))
    elif len(set(v)) == 2:
        cnt1 = 0
        cnt2 = 0
        tmp1 = list(set(v))
        tmp2 = [tmp1[1], tmp1[0]]
        # even = v[::2]
        # odd = v[1::2]
        #
        for i, a in enumerate(v):
            if i % 2 == 0:
                if a == tmp1[0]:
                    cnt1 += 1
                if a == tmp2[0]:
                    cnt2 += 1
            else :
                if a == tmp1[1]:
                    cnt1 += 1
                if a == tmp2[1]:
                    cnt2 += 1
        print((n-max(cnt1,cnt2)))
    else:
        even = v[::2]
        odd = v[1::2]
        count_e = collections.Counter(even)
        count_o = collections.Counter(odd)
        ce = count_e.most_common()
        co = count_o.most_common()
        if ce[0][0] != co[0][0]:
            print((n-ce[0][1] - co[0][1]))
        else:
            if len(ce) == 1:
                print((n-co[1][1]))
            elif len(co) == 1:
                print((n-ce[1][1]))
            else:
                print((min(n-ce[0][1]-co[1][1], n-ce[1][1]-co[0][1])))




if __name__ == '__main__':
    main()


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

    even = v[::2]
    odd = v[1::2]
    count_e = collections.Counter(even)
    count_o = collections.Counter(odd)
    ce = count_e.most_common()
    co = count_o.most_common()
    if ce[0][0] != co[0][0]:
        print((n-ce[0][1] - co[0][1]))
    else:
        if len(ce) == 1 and len(co) == 1:
            print((n//2))
        elif len(ce) == 1:
            print((n-co[1][1]))
        elif len(co) == 1:
            print((n-ce[1][1]))
        else:
            print((min(n-ce[0][1]-co[1][1], n-ce[1][1]-co[0][1])))




if __name__ == '__main__':
    main()
# Original solution
from collections import Counter
n = int(eval(input()))
array = list(map(int,input().split()))
if len(set(array)) == 1:
    print((n//2))
    exit()
gu = []
ki = []
for i in range(n):
    if i % 2 == 0:
        gu.append(array[i])
    else:
        ki.append(array[i])
gu_c = Counter(gu)
ki_c = Counter(ki)
if gu_c.most_common()[0][0] != ki_c.most_common()[0][0]:
    print((n-(gu_c.most_common()[0][1]+ki_c.most_common()[0][1])))
elif gu_c.most_common()[0][1] < ki_c.most_common()[0][1]:
    print((n-(gu_c.most_common()[1][1]+ki_c.most_common()[0][1])))
elif gu_c.most_common()[0][1] > ki_c.most_common()[0][1]:
    print((n-(gu_c.most_common()[0][1]+ki_c.most_common()[1][1])))
else:
    print((n-(gu_c.most_common()[0][1]+max(gu_c.most_common()[1][1],ki_c.most_common()[1][1]))))

# Optimized solution
from collections import Counter
n = int(eval(input()))
array = list(map(int,input().split()))
if len(set(array)) == 1:
    print((n//2))
    exit()
gu = []
ki = []
for i in range(n):
    if i % 2 == 0:
        gu.append(array[i])
    else:
        ki.append(array[i])
gu_c = Counter(gu)
ki_c = Counter(ki)
gu_m = gu_c.most_common()
ki_m = ki_c.most_common()
if gu_m[0][0] != ki_m[0][0]:
    print((n-(gu_m[0][1]+ki_m[0][1])))
elif gu_m[0][1] < ki_m[0][1]:
    print((n-(gu_m[1][1]+ki_m[0][1])))
elif gu_m[0][1] > ki_m[0][1]:
    print((n-(gu_m[0][1]+ki_m[1][1])))
else:
    print((n-(gu_m[0][1]+max(gu_m[1][1],ki_m[1][1]))))
# Original solution
import collections
N=int(eval(input()))
V=list(map(int,input().split()))
l=N//2
V_odd=[]
V_eve=[]
for i in range(N):
  if i%2==0:
    V_odd.append(V[i])
  else:
    V_eve.append(V[i])

p_odd = list(collections.Counter(V_odd).most_common())
p_eve = list(collections.Counter(V_eve).most_common())
p_odd.append([0,0])
p_eve.append([0,0])

if p_odd[0][0]!=p_eve[0][0]:
  print((N-p_odd[0][1]-p_eve[0][1]))
  exit()
else:
  print((min(N-p_odd[0][1]-p_eve[1][1],N-p_odd[1][1]-p_eve[0][1])))


# Optimized solution
import collections
N=int(eval(input()))
V=list(map(int,input().split()))
l=N//2
V_odd=[]
V_eve=[]
for i in range(N):
  if i%2==0:
    V_odd.append(V[i])
  else:
    V_eve.append(V[i])

p_odd = list(collections.Counter(V_odd).most_common())
p_eve = list(collections.Counter(V_eve).most_common())
p_odd.append([0,0])
p_eve.append([0,0])

if p_odd[0][0]!=p_eve[0][0]:
  print((N-p_odd[0][1]-p_eve[0][1]))
else:
  print((min(N-p_odd[0][1]-p_eve[1][1],N-p_odd[1][1]-p_eve[0][1])))
# Original solution
from collections import Counter

n = int(eval(input()))
v = list(map(int,input().split()))
v1 = v[::2]
v2 = v[1::2]
v1_n = Counter(v1)
v1_N =v1_n.most_common()
v2_n = Counter(v2)
v2_N = v2_n.most_common()
if len(v1_N) == 1 and len(v2_N) == 1 and v1_N[0][0] == v2_N[0][0]:
    print((int(n/2)))
elif len(([k[0] for k in list(v1_n.items()) if k[1] == max(v1_n.values())])) == 1 and len(([k[0] for k in list(v2_n.items()) if k[1] == max(v2_n.values())])) == 1 and v1_N[0][0] == v2_N[0][0]:
    print((min(n-v1_N[0][1]-v2_N[1][1],n-v1_N[1][1]-v2_N[0][1])))
else:
    print((n-v1_N[0][1]-v2_N[0][1])) 

# Optimized solution
from collections import Counter

n = int(eval(input()))
v = list(map(int,input().split()))
v1 = v[::2]
v2 = v[1::2]
v1_N = Counter(v1).most_common()
v2_N = Counter(v2).most_common()
if len(v1_N) == 1 and len(v2_N) == 1 and v1_N[0][0] == v2_N[0][0]:
    print((int(n/2)))
elif v1_N[0] == v2_N[0]:
    print((min(n-v1_N[0][1]-v2_N[1][1],n-v1_N[1][1]-v2_N[0][1])))
else:
    print((n-v1_N[0][1]-v2_N[0][1]))
# Original solution
from collections import Counter

n = int(eval(input()))
v = list(map(int, input().split()))
v1 = sorted(list(Counter(v[::2]).items()), key=lambda x: x[1], reverse=True)
v2 = sorted(list(Counter(v[1::2]).items()), key=lambda x: x[1], reverse=True)
v1.append((0, 0))
v2.append((0, 0))
if v1[0][0] != v2[0][0]:
    print((n - v1[0][1] - v2[0][1]))
else:
    print((min(n - v1[0][1] - v2[1][1], n - v1[1][1] - v2[0][1])))

# Optimized solution
from collections import Counter

n = int(eval(input()))
v = list(map(int, input().split()))
v1 = Counter(v[::2]).most_common()
v2 = Counter(v[1::2]).most_common()
v1.append((0, 0))
v2.append((0, 0))
if v1[0][0] != v2[0][0]:
    print((n - v1[0][1] - v2[0][1]))
else:
    print((min(n - v1[0][1] - v2[1][1], n - v1[1][1] - v2[0][1])))
# Original solution
N=int(eval(input()))
*V,=list(map(int,input().split()))

from collections import*
C1=Counter(V[::2])
C1=sorted(list(C1.items()),key=lambda x:x[1])
C2=Counter(V[1::2])
C2=sorted(list(C2.items()),key=lambda x:x[1])

K1=C1[-1][0]
V1=C1[-1][1]
K2=C2[-1][0]
V2=C2[-1][1]
if V1>V2:
    if K1==K2:
        V2=C2[-2][1]
elif V2>V1:
    if K1==K2:
        V1=C1[-2][1]
else:
    if K1==K2:
        if len(set(V))==1:
            V2=0
        else:
            V2=max(C1[-2][1],C2[-2][1])

print((N-V1-V2))

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

from collections import*
C1=Counter(V[::2]).most_common()+[(0,0)]
C2=Counter(V[1::2]).most_common()+[(0,0)]

K1=C1[0][0]
V1=C1[0][1]
K2=C2[0][0]
V2=C2[0][1]
if K1==K2:
    if V1>V2:
        V2=C2[1][1]
    elif V2>V1:
        V1=C[1][1]
    else:
        V2=max(C1[1][1],C2[1][1])

print((N-V1-V2))
# Original solution
n = int(eval(input()))
vl = list(map(int,input().split()))
v1 = vl[::2]
v2 = vl[1::2]

def count(a):
  d = dict()
  for i in a:
    if i not in d:
      d[i] = 1
    else:
      d[i] += 1
  l = []
  for i in d:
    l.append([d[i],i])
  l.append([0,0])
  l.sort(reverse=1)
  return l

v1 = count(v1)
v2 = count(v2)
if v1[0][0] == v1[1][0] or v2[0][0] ==v2[1][0]:
  print((n-v1[0][0]-v2[0][0]))
elif v1[0][1] != v2[0][1]:
  print((n-v1[0][0]-v2[0][0]))
elif v1[1][0]+v2[0][0] > v1[0][0]+v2[1][0]:
  print((n-v1[1][0]-v2[0][0]))
else:
  print((n-v1[0][0]-v2[1][0]))

# Optimized solution
n = int(eval(input()))
vl = list(map(int,input().split()))
v1 = vl[::2]
v2 = vl[1::2]

def count(a):
  d = dict()
  for i in a:
    if i not in d:
      d[i] = 1
    else:
      d[i] += 1
  l = []
  for i in d:
    l.append([d[i],i])
  l.append([0,0])
  l.sort(reverse=1)
  return l

v1 = count(v1)
v2 = count(v2)
if v1[0][1] != v2[0][1]:
  print((n-v1[0][0]-v2[0][0]))
elif v1[1][0]+v2[0][0] > v1[0][0]+v2[1][0]:
  print((n-v1[1][0]-v2[0][0]))
else:
  print((n-v1[0][0]-v2[1][0]))
# Original solution
from collections import Counter


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


lst_o = lst_v[::2]
lst_e = lst_v[1::2]
cnt_o = Counter(lst_o).most_common() + [(0, 0)]
cnt_e = Counter(lst_e).most_common() + [(0, 0)]


if cnt_o[0][0] == cnt_e[0][0]:
    rem_number = max(cnt_o[0][1] + cnt_e[1][1], cnt_o[1][1] + cnt_e[0][1])
else:
    rem_number = cnt_o[0][1] + cnt_e[0][1]
ans = n - rem_number


print(ans)

# Optimized solution
from collections import Counter

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

ac = Counter(ls[::2]).most_common(2)
bd = Counter(ls[1::2]).most_common(2)

if ac[0][0] != bd[0][0]:
    print((n-ac[0][1]-bd[0][1]))
else:
    if len(ac) == 1 or len(bd) == 1:
        print((n//2))
    else:
        print((n-max(ac[0][1] + bd[1][1], ac[1][1] + bd[0][1])))
# Original solution
import sys
input = sys.stdin.readline
from collections import Counter
from operator import itemgetter

def mpsort(m):
	ary = sorted([[k, v] for (k, v) in list(m.items())], key=itemgetter(1), reverse=True)
	if len(ary) == 1:
		return ary[0], [0, 0]
	return ary[0], ary[1]

def main():
	n = int(input().strip())
	v = list(map(int, input().strip().split()))
	gu = [i for i in v[::2]]
	ki = [i for i in v[1::2]]
	gu_map = Counter(gu)
	ki_map = Counter(ki)
	gu_sum = sum(gu_map.values())
	ki_sum = sum(ki_map.values())
	# print(gu_map)
	gu_f, gu_s = mpsort(gu_map)
	ki_f, ki_s = mpsort(ki_map)

	if gu_f[0] == ki_f[0]:
			print((min(gu_sum - gu_s[1] + ki_sum - ki_f[1],
					  gu_sum - gu_f[1] + ki_sum - ki_s[1])))
	else:
		print((gu_sum - gu_f[1] + ki_sum - ki_f[1]))
		
if __name__ == '__main__':
	main()


# Optimized solution
import sys
input = sys.stdin.readline
from collections import Counter
from operator import itemgetter

def mpsort(m):
	ary = sorted([[k, v] for (k, v) in list(m.items())], key=itemgetter(1), reverse=True)
	if len(ary) == 1:
		return ary[0], [0, 0]
	return ary[0], ary[1]

def main():
	n = int(input().strip())
	v = list(map(int, input().strip().split()))
	gu = [i for i in v[::2]]
	ki = [i for i in v[1::2]]
	gu_map = Counter(gu)
	ki_map = Counter(ki)
	s = n//2
	# print(gu_map)
	gu_f, gu_s = mpsort(gu_map)
	ki_f, ki_s = mpsort(ki_map)

	if gu_f[0] == ki_f[0]:
			print((min(s - gu_s[1] + s - ki_f[1],
					  s - gu_f[1] + s - ki_s[1])))
	else:
		print((s - gu_f[1] + s - ki_f[1]))

if __name__ == '__main__':
	main()
# Original solution
#!/usr/bin/env python3

n = int(eval(input()))
a = list(map(int,input().split()))
cnt_odd = [0]*(10**5+1)# a[2k]での個数
cnt_even = [0]*(10**5+1)
for i in range(n):
    if i  %2: cnt_odd[a[i]] += 1
    else: cnt_even[a[i]] += 1
odd,idx_odd=list(zip(*sorted(zip(cnt_odd,list(range(10**5+1))))))
even,idx_even=list(zip(*sorted(zip(cnt_even,list(range(10**5+1))))))
#print(odd[-1],even[-2],odd[-2],even[-1])
if idx_even[-1]!=idx_odd[-1]:
    print((n - odd[-1] - even[-1]))
else:
    print((n - max(odd[-1]+even[-2],odd[-2]+even[-1])))
#ちゃんとテストケース書かないと落ちる


# Optimized solution
n = int(eval(input()))
v = list(map(int, input().split()))
freq_odd = [0] * (10 ** 5 + 1)
freq_even = [0] * (10 ** 5 + 1)
for i in range(n // 2):
    freq_odd[v[2 * i]] += 1
    freq_even[v[2 * i + 1]] += 1
# print(freq_odd[:10], freq_even[:10])
freq_even, id_even = list(zip(*sorted(zip(freq_even, list(range(10 ** 5 + 1))))))
freq_odd, id_odd = list(zip(*sorted(zip(freq_odd, list(range(10 ** 5 + 1))))))
# print(freq_odd[-2:], freq_even[-2:])
# print(id_even[-1], id_odd[-1])
if id_even[-1] != id_odd[-1]:
    print((n - freq_even[-1] - freq_odd[-1]))
else:
    print((min(n - freq_even[-2] - freq_odd[-1], n - freq_even[-1] - freq_odd[-2])))
# Original solution
n=int(eval(input()))
V=list(map(int,input().split()))

from collections import Counter
V_1=V[::2]
V_2=V[1::2]

V_1_counter=Counter(V_1).most_common()
V_2_counter=Counter(V_2).most_common()
c1 = V_1_counter
c2 = V_2_counter

if c1[0][0]!=c2[0][0]:
    print((n-c1[0][1]-c2[0][1]))
if c1[0][0]==c2[0][0]:
    if len(c1)==len(c2)==1:
        print((n//2))
    if len(c1)==1 and len(c2)!=1:
        print((n-c1[0][1]-c2[1][1]))
    if len(c2)==1 and len(c1)!=1:
        print((n-c1[1][1]-c2[0][1]))    
    if len(c1)>1 and len(c2)>1:    
        print((n-max(c1[1][1]+c2[0][1],c1[0][1]+c2[1][1])))

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

from collections import Counter
V_1=V[::2]
V_2=V[1::2]

V_1_counter=Counter(V_1).most_common()
V_2_counter=Counter(V_2).most_common()
# print(V_1_counter,V_2_counter)

V_1_max_1 = V_1_counter[0]
V_1_max_2=(0,0)
if len(V_1_counter)>1:
    V_1_max_2 = V_1_counter[1]
    
V_2_max_1=V_2_counter[0]
V_2_max_2=(0,0)
if len(V_2_counter)>1:
    V_2_max_2 = V_2_counter[1]
    
if V_1_max_1[0] != V_2_max_1[0]:
    ans = N-V_1_max_1[1]-V_2_max_1[1]
    
else:
    ans=N-max(V_1_max_1[1]+V_2_max_2[1],V_1_max_2[1]+V_2_max_1[1])
    
print(ans)