CodeEff/ECCO huggingface dataset:
# Original solution
#python3
from collections import Counter
n = int(eval(input()))
a = list(map(int, input().split()))

odd = [a[i] for i in range(n) if i%2==0]
even = [a[i] for i in range(n) if i%2!=0]

cntOdd = Counter(odd).most_common(2)
cntEven = Counter(even).most_common(2)

 

if cntOdd[0][0] != cntEven[0][0]:
    print((n - cntOdd[0][1] - cntEven[0][1]))
else:
    if len(cntEven) == 1 and len(cntEven):
        print((n//2))
    else:
        ans1 = n - cntOdd[1][1] - cntEven[0][1]
        ans2 = n - cntOdd[0][1] - cntEven[1][1]
        print((min(ans1, ans2)))


    
    
    

# Optimized solution
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from collections import Counter 
from collections import defaultdict
def main():
    n = int(readline())
    a = [int(i) for i in readline().split()]
    odd = Counter(a[::2]).most_common(2)
    even = Counter(a[1::2]).most_common(2)
    odd.append((-1, 0))
    even.append((-1, 0))
    if odd[0][0] == even[0][0]:
        print((min(n-odd[1][1]-even[0][1], n-odd[0][1]-even[1][1]))) 
    else:
        print((n-odd[0][1]-even[0][1]))
if __name__ == '__main__':
    main()
# Original solution
from collections import Counter
n = int(eval(input()))
*v, = list(map(int, input().split()))

odds = v[1::2]
evens = v[::2]
o = Counter(odds)
e = Counter(evens)
omx, *ol = sorted(list(o.items()), reverse=True, key=lambda x: x[1])
emx, *el = sorted(list(e.items()), reverse=True, key=lambda x: x[1])

if omx[0] != emx[0]:
    ans = n - omx[1] - emx[1]
else:
    if ol:
        ol = ol[0]
    else:
        ol = (0, 0)

    if el:
        el = el[0]
    else:
        el = (0, 0)

    a = n - omx[1] - el[1]
    b = n - emx[1] - ol[1]
    ans = min(a, b)

print(ans)

# Optimized solution
from collections import Counter
from itertools import product
n = int(eval(input()))
*v, = list(map(int, input().split()))
o = Counter(v[1::2])
e = Counter(v[::2])
o[0] = 0
e[0] = 0
o_ls = o.most_common(2)
e_ls = e.most_common(2)


ans = n
for (k1, v1), (k2, v2) in product(o_ls, e_ls):
    if k1 == k2:
        continue
    x = n - v1 - v2
    if ans > x:
        ans = x

print(ans)
# Original solution
from collections import *

N = int(eval(input()))
v_list = input().split()

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

v1_list = v_list[::2]
v2_list = v_list[1::2]

v1_count_list = Counter(v1_list).most_common()
v2_count_list = Counter(v2_list).most_common()

if v1_count_list[0][0] != v2_count_list[0][0]:
    print((len(v_list) - v1_count_list[0][1] - v2_count_list[0][1]))
else:
    countor1 = len(v_list) - v1_count_list[1][1] - v2_count_list[0][1]
    countor2 = len(v_list) - v1_count_list[0][1] - v2_count_list[1][1]
    print((min(countor1, countor2)))

# Optimized solution
from collections import *

N = int(eval(input()))
v_list = input().split()

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

v1_count_list = Counter(v_list[::2]).most_common()
v2_count_list = Counter(v_list[1::2]).most_common()

if v1_count_list[0][0] != v2_count_list[0][0]:
    leave_value = v1_count_list[0][1] + v2_count_list[0][1]
else:
    leave_value = max(v1_count_list[1][1] + v2_count_list[0][1], v1_count_list[0][1] + v2_count_list[1][1])
print((len(v_list) - leave_value))
# Original solution
from collections import *

N = int(eval(input()))
v_list = input().split()

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

v1_count_list = Counter(v_list[::2]).most_common()
v2_count_list = Counter(v_list[1::2]).most_common()

if v1_count_list[0][0] != v2_count_list[0][0]:
    leave_value = v1_count_list[0][1] + v2_count_list[0][1]
else:
    leave_value = max(v1_count_list[1][1] + v2_count_list[0][1], v1_count_list[0][1] + v2_count_list[1][1])
print((len(v_list) - leave_value))

# Optimized solution
from collections import *

N = eval(input())
v_list = input().split()

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

v1_count_list = Counter(v_list[::2]).most_common(2)
v2_count_list = Counter(v_list[1::2]).most_common(2)

if v1_count_list[0][0] != v2_count_list[0][0]:
    leave_value = v1_count_list[0][1] + v2_count_list[0][1]
else:
    leave_value = max(v1_count_list[1][1] + v2_count_list[0][1], v1_count_list[0][1] + v2_count_list[1][1])
print((len(v_list) - leave_value))
# Original solution
def main():
    n, *v = list(map(int, open(0).read().split()))
    be = [0] * int(1e5)
    bo = [0] * int(1e5)
    for e, o in zip(*[iter(v)] * 2):
        be[e - 1] += 1
        bo[o - 1] += 1
    if be.index(max(be)) == bo.index(max(bo)):
        ve = max(be)
        vo = max(bo)
        be[be.index(ve)] = 0
        bo[bo.index(vo)] = 0
        print((min(n - ve - max(bo), n - vo - max(be))))
    else:
        print((n - max(be) - max(bo)))
    return


main()


# Optimized solution
def main():
    n, *v = list(map(int, open(0).read().split()))
    be = [0] * int(1e5)
    bo = [0] * int(1e5)
    for e, o in zip(*[iter(v)] * 2):
        be[e - 1] += 1
        bo[o - 1] += 1
    ve = max(be)
    vo = max(bo)
    ke = be.index(ve)
    ko = bo.index(vo)
    if ke == ko:
        be[ke] = 0
        bo[ko] = 0
        print((min(n - ve - max(bo), n - vo - max(be))))
    else:
        print((n - ve - vo))
    return


main()
# Original solution
from collections import Counter
n = int(eval(input()))
s = list(map(int, input().split()))
evenL = []
oddL = []
for i, v in enumerate(s):
  if i % 2 == 0:
    evenL.append(v)
  else:
    oddL.append(v)
    
evenLc = Counter(evenL)
oddLc = Counter(oddL)

evenLcs = sorted(list(evenLc.items()), key=lambda x: -x[1])
oddLcs = sorted(list(oddLc.items()), key=lambda x: -x[1])

if evenLcs[0][0] != oddLcs[0][0]:
  print((n - evenLcs[0][1] - oddLcs[0][1]))
else:
  if len(evenLc) == 1 and len(oddLc) == 1:
    print((n - len(evenL)))
    exit()
  if evenLcs[0][1] > oddLcs[0][1]:
    print((n - evenLcs[0][1] - oddLcs[1][1]))
  elif evenLcs[0][1] < oddLcs[0][1]:
    print((n - evenLcs[1][1] - oddLcs[0][1]))
  else:
    print((n - evenLcs[0][1] - max(evenLcs[1][1], oddLcs[1][1])))

# Optimized solution
from collections import Counter as C
n = int(eval(input()))
V = list(input().split())

V1 = C(V[::2]).most_common()
V2 = C(V[1::2]).most_common()

if V1[0][0] != V2[0][0]:
  ans = n - (V1[0][1] + V2[0][1])
else:
  l = V1[0][1] + V2[1][1] if len(V2) > 1 else V1[0][1]
  r = V1[1][1] + V2[0][1] if len(V1) > 1 else V2[0][1] 
  if l >= r:
    ans = n - l
  else:
    ans = n - r
print(ans)
# Original solution
n = int(eval(input()))
V = list(map(int, input().split()))
E = {}
O = {}
n = 1
for i, v in enumerate(V):
    if n:
        if v in list(E.keys()):
            E[v] += 1
        else:
            E[v] = 1
    else:
        if v in list(O.keys()):
            O[v] += 1
        else:
            O[v] = 1
    n = 1 - n
E = sorted(list(E.items()), key=lambda x: -x[1])
O = sorted(list(O.items()), key=lambda x: -x[1])
if E[0][0] != O[0][0]:
    ans = sum([x[1] for x in E])-E[0][1]
    ans += sum([x[1] for x in O])-O[0][1]
    print(ans)
else:
    if len(E) == 1 and len(O) == 1:
        print((E[0][1]))
    elif len(E) == 1:
        ans = sum([x[1] for x in E])-E[0][1]
        ans += sum([x[1] for x in O])-O[1][1]
        print(ans)
    elif len(O) == 1:
        ans = sum([x[1] for x in E])-E[1][1]
        ans += sum([x[1] for x in O])-O[0][1]
        print(ans)
    else:
        ans1 = sum([x[1] for x in E])-E[0][1]
        ans1 += sum([x[1] for x in O])-O[1][1]
        ans2 = sum([x[1] for x in E])-E[1][1]
        ans2 += sum([x[1] for x in O])-O[0][1]
        print((min(ans1, ans2)))

# Optimized solution
n = int(eval(input()))
V = list(map(int, input().split()))
E = {}
O = {}
now = 1
for i, v in enumerate(V):
    if now:
        if v in list(E.keys()):
            E[v] += 1
        else:
            E[v] = 1
    else:
        if v in list(O.keys()):
            O[v] += 1
        else:
            O[v] = 1
    now = 1 - now
E = sorted(list(E.items()), key=lambda x: -x[1])
O = sorted(list(O.items()), key=lambda x: -x[1])
if E[0][0] != O[0][0]:
    print((n - E[0][1] - O[0][1]))
else:
    if len(E) == 1 and len(O) == 1:
        print((E[0][1]))
    elif len(E) == 1:
        print((n-E[0][1]-O[1][1]))
    elif len(O) == 1:
        print((n-E[1][1]-O[0][1]))
    else:
        print((min(n-E[0][1]-O[1][1], n-E[1][1]-O[0][1])))
# Original solution
import collections

N = int(eval(input()))
V = [int(_) for _ in input().split()]

def calc(vs):
    r = dict(collections.Counter(vs))
    r[0] = 0
    ri = list(r.items())
    return sorted(ri, key=lambda x:-x[1])

ve = calc(V[::2])
vo = calc(V[1::2])

result = 0

if ve[0][0] != vo[0][0]:
    result = N - ve[0][1] - vo[0][1]
else:
    result = min(N - ve[0][1] - vo[1][1], N - ve[1][1] - vo[0][1])

print(result)



# Optimized solution
import collections

N = int(eval(input()))
V = [int(_) for _ in input().split()]

def calc(vs):
    cs = collections.Counter(vs)
    cs[0] = 0
    return cs.most_common()

ve = calc(V[::2])
vo = calc(V[1::2])

result = 0

if ve[0][0] != vo[0][0]:
    result = N - ve[0][1] - vo[0][1]
else:
    result = N - max(ve[0][1] + vo[1][1], ve[1][1] + vo[0][1])

print(result)
# Original solution
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import Counter
from operator import itemgetter
def main():
    n=int(eval(input()))
    V=[int(_) for _ in input().split()]
    even=V[0::2]
    odd=V[1::2]
    even_c=Counter(even)
    odd_c=Counter(odd)
    even_ci,odd_ci=list(even_c.items()),list(odd_c.items())
    even_ci.sort(key=itemgetter(1),reverse=True)
    odd_ci.sort(key=itemgetter(1),reverse=True)
    if even_ci[0][0]==odd_ci[0][0]:
        if len(even_ci)>1 and len(odd_ci)>1:
            print((min(sum(even_c.values())-even_ci[1][1]+sum(odd_c.values())-odd_ci[0][1],
                        sum(even_c.values())-even_ci[0][1]+sum(odd_c.values())-odd_ci[1][1])))
        elif len(even_ci)>1 and len(odd_ci)==1:
            print((sum(even_c.values())-even_ci[1][1]))        
        elif len(even_ci)==1 and len(odd_ci)>1:
            print((sum(odd_c.values())-odd_ci[0][1]))        
        else:
            print((n//2))   
    else:
        print((sum(even_c.values())-even_ci[0][1]+sum(odd_c.values())-odd_ci[0][1]))

if __name__=='__main__':
    main()

# Optimized solution
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import Counter
from operator import itemgetter
def main():
    n=int(eval(input()))
    V=[int(_) for _ in input().split()]
    even,odd=V[0::2],V[1::2]
    even_c,odd_c=Counter(even),Counter(odd)
    even_ci,odd_ci=list(even_c.items()),list(odd_c.items())
    even_ci.sort(key=itemgetter(1),reverse=True)
    odd_ci.sort(key=itemgetter(1),reverse=True)
    if even_ci[0][0]==odd_ci[0][0]:
        if len(even_ci)>1 and len(odd_ci)>1:
            print((min(sum(even_c.values())-even_ci[1][1]+sum(odd_c.values())-odd_ci[0][1],
                        sum(even_c.values())-even_ci[0][1]+sum(odd_c.values())-odd_ci[1][1])))
        elif len(even_ci)>1 and len(odd_ci)==1:
            print((sum(even_c.values())-even_ci[1][1]))        
        elif len(even_ci)==1 and len(odd_ci)>1:
            print((sum(odd_c.values())-odd_ci[0][1]))        
        else:
            print((n//2))   
    else:
        print((sum(even_c.values())-even_ci[0][1]+sum(odd_c.values())-odd_ci[0][1]))

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

n = int(eval(input()))
v = list(map(int, input().split()))
even_odd_length = n / 2
replace_total = 0

list_odd = v[0::2]
list_even = v[1::2]

dict_c_odd = dict(collections.Counter(list_odd))
dict_c_even = dict(collections.Counter(list_even))
dict_c_even_bk = dict_c_even.copy()
dict_c_odd_bk = dict_c_odd.copy()

replace_total_tmp = 0
replace_total_tmp2 = 0
max_count_c_odd = max(dict_c_odd.values())
max_count_c_even = max(dict_c_even.values())
max_count_c_even_bk = max_count_c_even
max_c_odd_keys = [k for k, v in list(dict_c_odd.items()) if v == max_count_c_odd]
max_c_even_keys = [k for k, v in list(dict_c_even.items()) if v == max_count_c_even]

if len(set(v)) == 1:
    print((int(even_odd_length)))
else:    
    if max_c_odd_keys[0] in dict_c_even:
        del dict_c_even[max_c_odd_keys[0]]
    max_count_c_even = max(dict_c_even.values())
    replace_total_tmp = (n - max_count_c_odd - max_count_c_even)
    
    dict_c_even = dict_c_even_bk
    max_count_c_even = max_count_c_even_bk
    
    if max_c_even_keys[0] in dict_c_odd:
        del dict_c_odd[max_c_even_keys[0]]
    max_count_c_odd = max(dict_c_odd.values())
    replace_total_tmp2 = (n - max_count_c_odd - max_count_c_even)
    
    if replace_total_tmp >= replace_total_tmp2:
         replace_total = replace_total_tmp2
    else:
         replace_total = replace_total_tmp
    print(replace_total)

# Optimized solution
import collections

n = int(eval(input()))
v = list(map(int, input().split()))
even_odd_length = n / 2
replace_total = 0

list_odd = v[0::2]
list_even = v[1::2]

dict_c_odd = dict(collections.Counter(list_odd))
dict_c_even = dict(collections.Counter(list_even))
dict_c_even_bk = dict_c_even.copy()

replace_total_tmp = 0
replace_total_tmp2 = 0

max_count_c_odd = max(dict_c_odd.values())
max_count_c_even = max(dict_c_even.values())
max_count_c_even_bk = max_count_c_even

max_c_odd_keys = [k for k, v in list(dict_c_odd.items()) if v == max_count_c_odd]
max_c_even_keys = [k for k, v in list(dict_c_even.items()) if v == max_count_c_even]

if len(set(v)) == 1:
    print((int(even_odd_length)))
else:    
    if max_c_odd_keys[0] in dict_c_even:
        del dict_c_even[max_c_odd_keys[0]]
    max_count_c_even = max(dict_c_even.values())
    replace_total_tmp = (n - max_count_c_odd - max_count_c_even)
    
    dict_c_even = dict_c_even_bk
    max_count_c_even = max_count_c_even_bk
    
    if max_c_even_keys[0] in dict_c_odd:
        del dict_c_odd[max_c_even_keys[0]]
    max_count_c_odd = max(dict_c_odd.values())
    replace_total_tmp2 = (n - max_count_c_odd - max_count_c_even)
    
    if replace_total_tmp >= replace_total_tmp2:
         replace_total = replace_total_tmp2
    else:
         replace_total = replace_total_tmp

    print(replace_total)
# Original solution
from collections import Counter
n=int(eval(input()))
l=list(map(int,input().split()))
f=l[0::2]
s=l[1::2]
ans=[]
if len(list(Counter(l).values())) == 1:
  ans.append(len(f))
elif len(list(Counter(f).values())) == len(list(Counter(s).values())) == 1:
  ans.append(0)
else:
  for fk,fv in list(Counter(f).items()):
    fdk=fk
    a=sum(Counter(f).values())-fv
    for sk,sv in list(Counter(s).items()):
      if fk != sk:
        ans.append(a+sum(Counter(s).values())-sv)
print((min(ans)))

# Optimized solution
from collections import Counter
n=int(eval(input()))
l=list(map(int,input().split()))
f=l[0::2]
s=l[1::2]
fn=sorted(list(Counter(f).items()),key=lambda x:x[1],reverse=True) + [(0, 0)]
sn=sorted(list(Counter(s).items()),key=lambda x:x[1],reverse=True) + [(0, 0)]
if fn[0][0]!=sn[0][0]:
  ans=n-fn[0][1]-sn[0][1]
else:
  ans=n-max(fn[1][1]+sn[0][1],fn[0][1]+sn[1][1])
print(ans)
# Original solution
n = int(eval(input()))
v = list(map(int, input().split()))

va, ve = v[0::2], v[1::2]
add, even = va[0], ve[0]
for a in set(va):
  add = a if va.count(add) < va.count(a) else add
for e in set(ve):
  even = e if ve.count(even) < ve.count(e) else even

print((len(v)-va.count(add)-ve.count(even) if add!=even else len(v)-va.count(add)))

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

va, ve = v[0::2], v[1::2]
da, de = {}, {}
for a in va:
  da[a] = da.get(a, 0)+1
for e in ve:
  de[e] = de.get(e, 0)+1
add = sorted([(k,v) for k,v in list(da.items())], key=lambda x:-x[1])+[(0,0)]
even = sorted([(k,v) for k,v in list(de.items())], key=lambda x:-x[1])+[(0,0)]
if add[0][0] == even[0][0]:
  if add[1][1] <= even[1][1]:
    even.pop(0)
  else:
    add.pop(0)
print((n-add[0][1]-even[0][1]))
# Original solution
from collections import Counter

iN = int(eval(input()))
aV = [int(_) for _ in input().split()]

oV0 = Counter(aV[0::2]).most_common(2)
oV1 = Counter(aV[1::2]).most_common(2)
oV0 += [(0,0)]
oV1 += [(0,0)]

if oV0[0][0] != oV1[0][0] :
    print((iN - oV0[0][1] - oV1[0][1]))
else:
    print((iN - max(oV0[0][1],oV1[0][1]) - max(oV0[1][1],oV1[1][1])))


# Optimized solution
from collections import Counter

def fParse(iN,aV):
    oV0 = Counter(aV[0::2]).most_common(2)
    oV1 = Counter(aV[1::2]).most_common(2)
    oV0 += [(0,0)]
    oV1 += [(0,0)]

    if oV0[0][0] != oV1[0][0] :
        return iN - oV0[0][1] - oV1[0][1]
    else:
        return iN - max(oV0[0][1],oV1[0][1]) - max(oV0[1][1],oV1[1][1])

if __name__ == "__main__":
    iN = int(eval(input()))
    aV = [int(_) for _ in input().split()]
    print((fParse(iN,aV)))
# Original solution
N = int(eval(input()))
V = list(map(int,input().split()))
even = [0]*(10**5+10)
odd = [0]*(10**5+10)
for v in V[::2]:
  odd[v] += 1
for v in V[1::2]:
  even[v] += 1
omax = max(odd)
emax = max(even)
if(even.index(emax) != odd.index(omax)):
  print((N - emax - omax))
else:
  even.sort()
  odd.sort()
  print((min(N - even[-1] - odd[-2], N - even[-2] - odd[-1])))

# Optimized solution
def ans():
  N = int(eval(input()))
  V = list(map(int,input().split()))
  even = [0]*100001
  odd = [0]*100001
  for v in V[1::2]:
    even[v] += 1
  for v in V[::2]:
    odd[v] += 1
  me = max(even)
  mo = max(odd)
  if(even.index(me) != odd.index(mo)):
    print((N - me - mo))
  else:
    even.sort()
    odd.sort()
    print((min(N-even[-1]-odd[-2], N-even[-2]-odd[-1])))
ans()
# Original solution
from collections import Counter


n = int(eval(input()))
v = list(map(int, input().split()))
v_former = sorted([(v, k) for k, v in list(Counter(v[::2]).items())], reverse=True) + [(0, 0)]
v_latter = sorted([(v, k) for k, v in list(Counter(v[1::2]).items())], reverse=True) + [(0, 0)]
if v_former[0][1] != v_latter[0][1]:
    print((n - v_former[0][0] - v_latter[0][0]))
else:
    print((n - max(v_former[0][0] + v_latter[1][0], v_former[1][0] + v_latter[0][0])))



# Optimized solution
from collections import Counter


n = int(eval(input()))
v = list(map(int, input().split()))
v_former = Counter(v[::2]).most_common() + [(0, 0)]
v_latter = Counter(v[1::2]).most_common() + [(0, 0)]
if v_former[0][0] != v_latter[0][0]:
    print((n - v_former[0][1] - v_latter[0][1]))
else:
    print((n - max(v_former[0][1] + v_latter[1][1], v_former[1][1] + v_latter[0][1])))
# Original solution
'''
問題文
数列 a1,a2,...,anが以下の条件を満たすとき、 /\/\/\/ と呼ぶことにします。

・各 i=1,2,...,n−2について、ai=ai+2
・数列に現れる数はちょうど 2種類

偶数長の数列 v1,v2,...,vnが与えられます。 要素をいくつか書き換えることでこの数列を /\/\/\/ にしたいです。
書き換える要素の数は最小でいくつになるか求めてください。

制約
2≤n≤105
nは偶数
1≤vi≤105
viは整数
'''

n=int(eval(input()))
v=input().split()
vodd=[]
veven=[]
for i in range(n):
    if i%2:
        veven.append(int(v[i]))
    else:
        vodd.append(int(v[i]))

voddNum=[vodd[0]]
voddCnt=[0]
j=0
for i,odd in enumerate(vodd):
    if voddNum[j]!=odd:
        for k,num in enumerate(voddNum):
            if num==odd:
                j=k
                break
        else:
            j=k+1
            voddNum.append(odd)
            voddCnt.append(0)
    voddCnt[j]+=1
voddSet=list(zip(voddCnt, voddNum))
#voddSet=list(reversed(sorted(voddSet,key=lambda x:x[0])))
voddSet.sort(key=lambda x:x[0])
voddSet.reverse()
# print(vodd)
# print(voddNum)
# print(voddCnt)
# print(voddSet)


vevenNum=[veven[0]]
vevenCnt=[0]
j=0
for i,even in enumerate(veven):
    if vevenNum[j]!=even:
        for k,num in enumerate(vevenNum):
            if num==even:
                j=k
                break
        else:
            j=k+1
            vevenNum.append(even)
            vevenCnt.append(0)
    vevenCnt[j]+=1
vevenSet=list(zip(vevenCnt, vevenNum))
#vevenSet=list(reversed(sorted(vevenSet,key=lambda x:x[0])))
vevenSet.sort(key=lambda x:x[0])
vevenSet.reverse()
# print()
# print(veven)
# print(vevenNum)
# print(vevenCnt)
# print(vevenSet)


changeCnt=len(vodd)+len(veven)
if voddSet[0][1]==vevenSet[0][1]:
    if len(voddSet)==1 & len(vevenSet)==1:
        changeCnt-=len(vodd)
    elif len(voddSet)==1:
        changeCnt-=vevenSet[0][0]
    elif len(vevenSet)==1:
        changeCnt-=voddSet[0][0]
    else:
        if voddSet[1][0]>vevenSet[1][0]:
            changeCnt=changeCnt-voddSet[1][0]-vevenSet[0][0]
        else:
            changeCnt+=-voddSet[0][0]-vevenSet[1][0]
else:
    changeCnt+=-voddSet[0][0]-vevenSet[0][0]

print(changeCnt)
#'''


# Optimized solution
n=int(eval(input()))
v=list(map(int,input().split()))
vodd={-1:0}
veven={-1:0}
for i,vi in enumerate(v):
    if i%2:
        if(vi in veven):
            veven[vi]+=1
        else:
            veven[vi]=1
    else:
        if(vi in vodd):
            vodd[vi]+=1
        else:
            vodd[vi]=1
veven=list(veven.items())
veven.sort(key=lambda x:-x[1])
vodd=list(vodd.items())
vodd.sort(key=lambda x:-x[1])
if veven[0][0]==vodd[0][0]:
    a=veven[0][1]+vodd[1][1]
    b=veven[1][1]+vodd[0][1]
    changeCnt=n-a if a>b else n-b
else:
    changeCnt=n-veven[0][1]-vodd[0][1]

print(changeCnt)
# Original solution
from collections import Counter


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


if len(set(lst_v)) == 1:
    ans = n // 2
else:
    lst_odd = lst_v[::2]
    lst_even = lst_v[1::2]
    cnt_odd = sorted(list(Counter(lst_odd).items()), key=lambda x: -x[1])
    cnt_even = sorted(list(Counter(lst_even).items()), key=lambda x :-x[1])

    if cnt_odd[0][0] == cnt_even[0][0]:
        rem_number = max(cnt_odd[0][1] + cnt_even[1][1], cnt_odd[1][1] + cnt_even[0][1])
    else:
        rem_number = cnt_odd[0][1] + cnt_even[0][1]
    sum_odd = sum(t[1] for t in cnt_odd)
    sum_even = sum(t[1] for t in cnt_even)
    ans = sum_odd + sum_even - rem_number


print(ans)


# Optimized solution
# C
import collections
n = int(eval(input()))
lst = list(map(int, input().split()))
lst1 = lst[::2]
lst2 = lst[1::2]
dct1 = sorted(list(dict(collections.Counter(lst1)).items()), key=lambda x:-x[1])
dct2 = sorted(list(dict(collections.Counter(lst2)).items()), key=lambda x:-x[1])


ans = 0
if (len(dct1) == 1 and len(dct2) == 1):
	if (dct1[0][0] == dct2[0][0]):
		ans = dct1[0][1]
	else:
		ans = 0
elif (len(dct1) == 1 and len(dct2) > 1):
	if (dct1[0][0] == dct2[0][0]):
		ans = n // 2 - dct2[1][1]
	else:
		ans = n // 2 - dct2[0][1]
elif (len(dct2) == 1 and len(dct1) > 1):
	if (dct1[0][0] == dct2[0][0]):
		ans = n // 2 - dct1[1][1]
	else:
		ans = n // 2 - dct1[0][1]
elif (len(dct1) > 1 and len(dct2) > 1):
	if (dct1[0][0] == dct2[0][0]):
		ans = n - max(dct1[0][1] + dct2[1][1], dct1[1][1] + dct2[0][1])
	else:
		ans = n - dct1[0][1] - dct2[0][1]
print(ans)
# Original solution
from collections import Counter

n=int(eval(input()))
V=list(map(int,input().split()))
V_1=[(0,0)]+sorted(list(Counter([V[i] for i in range(n) if i%2==0]).items()), key=lambda x:x[1])
V_2=[(0,0)]+sorted(list(Counter([V[j] for j in range(n) if j%2==1]).items()), key=lambda x:x[1])

a,b=V_1[-1][0],V_2[-1][0]

if a==b:
    if V_1[-2][1]>V_2[-2][1]:a=V_1[-2][0]
    else:b=V_2[-2][0]

cnt=0
for i in range(n):
    if i%2==0:
        if V[i]!=a:cnt +=1
    else:
        if V[i]!=b:cnt +=1

print(cnt)

# Optimized solution
from collections import Counter
n=int(eval(input()))
V=list(map(int,input().split()))

even=[(0,0)]+sorted(list(Counter(V[::2]).items()), key=lambda x:x[1])
odd=[(0,0)]+sorted(list(Counter(V[1::2]).items()), key=lambda x:x[1])

if even[-1][0]==odd[-1][0]:
    if even[-2][1]>odd[-2][1]:even=even[-2][0];odd=odd[-1][0]
    else:even=even[-1][0];odd=odd[-2][0]
else:even=even[-1][0];odd=odd[-1][0]

cnt=0
for i,j in enumerate(V):
    if i%2==0 and j!=even:cnt +=1
    elif i%2==1 and j!=odd:cnt +=1

print(cnt)