CodeEff/ECCO huggingface dataset:
# Original solution
_ = eval(input())
seq = list(map(int,input().split()))
 
seq1 = seq[::2]
seq2 = seq[1::2]
 
if len(set(seq)) == 1:
    print((len(seq2)))
    exit()
    
def count_dictonary(seq):
    ret_dict={}
    for item in seq:
        if item not in ret_dict:
            ret_dict[item] = 1
        else:
            ret_dict[item]+=1
    return ret_dict
 
def modes(counting_dict):
    #(11,2),(2,1),(3,3)
    ret={}
    for item in list(counting_dict.items()):
        no, count = item
        if counting_dict[no] in ret:
            ret[count].append(no)
        else:
            ret[count]=[no]
            
    return ret
 
 
counting1 = count_dictonary(seq1)
counting2 = count_dictonary(seq2)
 
modes1 = sorted(list(modes(counting1).items()),reverse=True)
modes2 = sorted(list(modes(counting2).items()),reverse=True)
 
min_change=len(seq)
if modes1[0][1] != modes2[0][1] or len(modes1[0][1]) >=2 or len(modes2[0][1]) >=2:
    min_change = (len(seq1) - modes1[0][0]) + (len(seq2) - modes2[0][0])
else:
    m01=len(seq)
    m10=len(seq)
    if len(modes2) !=1:
        m01 =  (len(seq1) - modes1[0][0]) + (len(seq2) - modes2[1][0])
    if len(modes1) !=1:
        m10 =  (len(seq1) - modes1[1][0]) + (len(seq2) - modes2[0][0])
    min_change = min(m01,m10)
    
print(min_change)

# Optimized solution
def count_char_occurrence(seq):
    # count how many times characters occur and return results as a dictionary
    ret = {}
    for char in seq:
        if char in ret:
            ret[char] += 1
        else:
            ret[char] = 1
    return ret


def accum_char_frequency(seq):
    """
    accumulate frequency of each number in a inputted sequence
    Example:
        in: [a,a,a,a,b,b,b,b,c]
        out: { 4 times: [a,b] , 1 times: [c] }
    """
    frequencies = count_char_occurrence(seq)

    ret = {}
    for char, count in list(frequencies.items()):
        if count in ret:
            ret[count].append(char)
        else:
            ret[count] = [char]
    return ret


def main():
    _ = eval(input())
    seq = list(map(int, input().split()))

    odd = seq[::2]
    even = seq[1::2]

    if len(set(seq)) == 1:  # when all chars are unique, return the length of even numbered chars
        print((len(even)))
        return

    no_freq_odd = accum_char_frequency(odd)
    freq_odd = sorted(list(no_freq_odd.items()), reverse=True)
    
    no_freq_even = accum_char_frequency(even)
    freq_even = sorted(list(no_freq_even.items()), reverse=True)

    if len(freq_odd[0][1]) == 1 and len(freq_even[0][1]) == 1 and freq_odd[0][1] == freq_even[0][1]:
        min_change_even = len(seq)
        if len(freq_even) != 1:
            min_change_even = (len(odd) - freq_odd[0][0]) + (len(even) - freq_even[1][0])

        min_change_odd = len(seq)
        if len(freq_odd) != 1:
            min_change_odd = (len(odd) - freq_odd[1][0]) + (len(even) - freq_even[0][0])

        print((min(min_change_even, min_change_odd)))
        return
    else:
        min_change = (len(odd) - freq_odd[0][0]) + (len(even) - freq_even[0][0])
        print(min_change)
        return

main()
# Original solution
# coding: utf-8
# hello worldと表示する
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(eval(input()))
def MI(): return list(map(int, input().split()))
def LI(): return list(map(int, input().split()))
def LI2(): return [int(eval(input())) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print(('\n'.join(x)))
def printni(x): print(('\n'.join(list(map(str,x)))))
inf = 10**17
mod = 10**9 + 7

n=I()
lis=LI()
ev,od=[],[]
for i in range(n):
    if i%2==0:
        ev.append(lis[i])
    else:
        od.append(lis[i])
c=Counter(ev)
d=Counter(od)
#print(c.most_common()[0][1])
#-c.most_common()[0]-d.most_common()[0]
if c.most_common()[0][0]==d.most_common()[0][0]:
    if c.most_common()[0][1]==n//2:
        ans=n//2
    elif c.most_common()[1][1]>=d.most_common()[1][1]:
        ans=len(od)-d.most_common()[0][1]+len(ev)-c.most_common()[1][1]
    elif c.most_common()[1][1]<d.most_common()[1][1]:
        ans=len(od)-c.most_common()[0][1]+len(ev)-d.most_common()[1][1]
else:
    ans=len(ev)+len(od)-c.most_common()[0][1]-d.most_common()[0][1]
print(ans)

# Optimized solution
# coding: utf-8
# hello worldと表示する
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(eval(input()))
def MI(): return list(map(int, input().split()))
def LI(): return list(map(int, input().split()))
def LI2(): return [int(eval(input())) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print(('\n'.join(x)))
def printni(x): print(('\n'.join(list(map(str,x)))))
inf = 10**17
mod = 10**9 + 7

n=I()//2
lis=LI()
lis1=[]
lis2=[]
for i in range(n):
    lis1.append(lis[2*i])
    lis2.append(lis[2*i+1])
x=Counter(lis1).most_common(2)
y=Counter(lis2).most_common(2)
#print(x)
#print(y)
if len(x)==1:
    x.append((0,0))
if len(y)==1:
    y.append((-1,0))
#print(x)
#print(y)
if x[0][0]!=y[0][0]:
    print((2*n-x[0][1]-y[0][1]))
else:
    cands=[]
    #print(2*n-x[0][1]-y[1][]))
    if x[1][0]!=y[0][0]:
        cands.append(2*n-x[1][1]-y[0][1])
    if x[0][0]!=y[1][0]:
        cands.append(2*n-x[0][1]-y[1][1])
    if x[1][0]!=y[1][0]:
        cands.append(2*n-x[1][1]-y[1][1])
    print((min(cands)))
# Original solution
import collections

n = int(eval(input()))
odd = []
even = []
for i, j in enumerate(map(int, input().split())):
    if i % 2 == 0:
        even += [j]
    else:
        odd += [j]
odd = sorted(list(collections.Counter(odd).items()), reverse=True, key=lambda x: x[1])
even = sorted(list(collections.Counter(even).items()), reverse=True, key=lambda x: x[1])

if len(odd) == 1 and len(even) == 1 and odd[0][0] == even[0][0]:
    print((n // 2))
elif odd[0][0] == even[0][0]:
    if odd[0][1] == even[0][1]:
        for i in range(2):
            if odd[i][1] == even[i][1]:
                continue
            elif odd[i][1] > even[i][1]:
                print(((n // 2 - odd[1][1]) + (n // 2 - even[0][1])))
                break
            elif odd[i][1] < even[i][1]:
                print(((n // 2 - odd[0][1]) + (n // 2 - even[1][1])))
                break
        else:
            print(((n // 2 - odd[0][1]) + (n // 2 - even[1][1])))
else:
    print(((n // 2 - odd[0][1]) + (n // 2 - even[0][1])))


# Optimized solution
import collections


n = int(eval(input()))
odd = []
even = []
for i,j in enumerate(map(int,input().split())):
    if i % 2 == 0:
        even += [j]
    else:
        odd += [j]
odd = sorted(list(collections.Counter(odd).items()),key=lambda x:(x[1]),reverse=True)
even = sorted(list(collections.Counter(even).items()),key=lambda x:(x[1]),reverse=True)

if len(odd) == 1 and len(even) == 1:
    if odd[0][0] == even[0][0]:
        print((n//2))
        exit()
    else:
        print((0))
        exit()

if odd[0][0] == even[0][0]:
    if len(odd) >= 2 and len(even) >= 2:
        if odd[0][1] + even[1][1] > odd[1][1] + even[0][1]:
            print(((n//2 - odd[0][1]) + (n//2 - even[1][1])))
        else:
            print(((n//2 - odd[1][1]) + (n//2 - even[0][1])))
    else:
        if len(odd) == 1:
            print(((n//2 - odd[0][1]) + (n//2 - even[1][1])))
        else:
            print(((n//2 - odd[1][1]) + (n//2 - even[0][1])))
else:
    print(((n//2 - odd[0][1]) + (n//2 - even[0][1])))
# Original solution
def main():
    from collections import Counter
    n = int(eval(input()))
    V = list(map(int,input().split()))
    odds = []
    evens = []
    for i,v in enumerate(V):
        if i & 1:
            evens.append(v)
        else:
            odds.append(v)
    
    odds_counter = list(Counter(odds).items())
    eves_counter = list(Counter(evens).items())
    
    odds_counter.sort(reverse=True, key= lambda x: x[1])
    eves_counter.sort(reverse=True, key= lambda x: x[1])

    if odds_counter[0][0] != eves_counter[0][0]:
        print((len(odds)- odds_counter[0][1] + len(evens) - eves_counter[0][1]))
    else:
        odds_counter.append((-1,0))
        eves_counter.append((-1,0))

        print((
            min(
                len(odds)-odds_counter[0][1] + len(evens) - eves_counter[1][1],
                len(odds)-odds_counter[1][1] + len(evens) - eves_counter[0][1],
            )
        ))
            
        

    

    
    
    


main()

# Optimized solution
def main():
    from collections import Counter
    n = int(eval(input()))
    V = list(map(int,input().split()))
    odds = []
    evens = []
    for i,v in enumerate(V):
        if i & 1:
            evens.append(v)
        else:
            odds.append(v)
    
    odds_modes= Counter(odds).most_common(2)
    evens_modes = Counter(evens).most_common(2)

    if odds_modes[0][0] != evens_modes[0][0]:
        print((len(odds)- odds_modes[0][1] + len(evens) - evens_modes[0][1]))
    else:
        odds_modes.append((-1,0))
        evens_modes.append((-1,0))

        print((
            min(
                len(odds)-odds_modes[0][1] + len(evens) - evens_modes[1][1],
                len(odds)-odds_modes[1][1] + len(evens) - evens_modes[0][1],
            )
        ))
            

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

v1 = v[0::2]
v2 = v[1::2]

m1, m2 = {}, {}
for vi in v1:
    if vi in m1:
        m1[vi] += 1
    else:
        m1[vi] = 1
for vi in v2:
    c = m2[vi] if vi in m2 else 0
    m2[vi] = c + 1

p1 = [(k, m1[k]) for k in list(m1.keys())]
p2 = [(k, m2[k]) for k in list(m2.keys())]

p1.sort(key=lambda x: x[1], reverse=True)
p2.sort(key=lambda x: x[1], reverse=True)

if n == 2:
    if v1[0] == v2[0]:
        ans = 1
    else:
        ans = 0
else:
    if p1[0][0] == p2[0][0]:
        if p1[0][1] < p2[0][1]:
            ans = n - p2[0][1] - p1[1][1]
        elif p1[0][1] > p2[0][1]:
            ans = n - p1[0][1] - p2[1][1]
        else:
            h = p1[0][1]
            if len(p1) == 1:
                ans = n - h
            else:
                if p1[1][1] < p2[1][1]:
                    ans = n - h - p2[1][1]
                else:
                    ans = n - h - p1[1][1]
    else:
        ans = n - p1[0][1] - p2[0][1]
print(ans)


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

va = v[0::2]
vb = v[1::2]

ma, mb = {None: 0}, {None: 0}
for vi in va:
    c = ma[vi] if vi in ma else 0
    ma[vi] = c + 1
for vi in vb:
    c = mb[vi] if vi in mb else 0
    mb[vi] = c + 1

# items() is [(k, m[k]) for k in m.keys()]
pa = list(ma.items())
pb = list(mb.items())
pa.sort(key=lambda x: x[1], reverse=True)
pb.sort(key=lambda x: x[1], reverse=True)

if pa[0][0] == pb[0][0]:
    if pa[0][1] < pb[0][1]:
        ans = n - pa[1][1] - pb[0][1]
    elif pa[0][1] > pb[0][1]:
        ans = n - pa[0][1] - pb[1][1]
    else:
        h = pa[0][1]
        if pa[1][1] < pb[1][1]:
            ans = n - h - pb[1][1]
        else:
            ans = n - h - pa[1][1]
else:
    ans = n - pa[0][1] - pb[0][1]
print(ans)
# Original solution
from collections import Counter
    
n = int(eval(input()))
v = list(map(int, input().split()))
odd = v[::2]
even = v[1::2]
    
c_even = Counter(even).most_common(2)
c_odd = Counter(odd).most_common(2)

    
if(c_even[0][0] != c_odd[0][0]):
    print((n - c_even[0][1] - c_odd[0][1]))
else:
    if(len(c_even) == 1):
        print((n//2))
    else:
        # second = max[c_even[1][1], c_odd[1][1]]
        # print(n - c_even[0][1] - second)
        print((n - max(c_even[0][1] + c_odd[1][1], c_even[1][1] + c_odd[0][1])))

# Optimized solution
from collections import Counter
    
n = int(eval(input()))
v = list(map(int, input().split()))
odd = v[::2]
even = v[1::2]
    
c_even = Counter(even).most_common(2)
c_odd = Counter(odd).most_common(2)

    
if(c_even[0][0] != c_odd[0][0]):
    print((n - c_even[0][1] - c_odd[0][1]))
else:
    if(len(c_even) == 1):
        print((n//2))
    else:
        # second = max[c_even[1][1], c_odd[1][1]]
        # print(n - c_even[0][1] - second)
        print((n - max(c_odd[1][1], c_even[1][1]) - c_even[0][1]))
# Original solution
# ABC111C - /\/\/\/
from collections import Counter


def main():
    N, *V = list(map(int, open(0).read().split()))
    even, odd = Counter(V[::2]).most_common(2), Counter(V[1::2]).most_common(2)
    if even[0][0] != odd[0][0]:  # replace except the modes of both parities
        ans = N - even[0][1] - odd[0][1]
    else:
        if len(even) == 1 or len(odd) == 1:
            ans = N // 2  #  replace half of the sequence
        else:  # replace smaller pair of even no.1 & odd 2 / even 2 & odd 1
            ans = N - max(even[0][1] + odd[1][1], even[1][1] + odd[0][1])
    print(ans)


if __name__ == "__main__":
    main()

# Optimized solution
# ABC111C - /\/\/\/
from collections import Counter


def main():
    N, *V = open(0).read().split()
    N = int(N)
    even, odd = Counter(V[::2]).most_common(2), Counter(V[1::2]).most_common(2)
    if even[0][0] != odd[0][0]:  # replace except the modes of both parities
        ans = N - even[0][1] - odd[0][1]
    else:
        if len(even) == 1 or len(odd) == 1:
            ans = N // 2  #  replace half of the sequence
        else:  # replace smaller pair of even no.1 & odd 2 / even 2 & odd 1
            ans = N - max(even[0][1] + odd[1][1], even[1][1] + odd[0][1])
    print(ans)


if __name__ == "__main__":
    main()
# Original solution
def main():
  n = int(eval(input()))
  v = input_list()
  evens = []
  odds = []
  vs = v[:]
  kind = len(set(vs))
  if kind == 1:
    print((n//2))
    exit(0)
  
  for i, vv in enumerate(v):
    if i % 2 == 0:
      evens.append(vv)
    else:
      odds.append(vv)
  ec = collections.Counter(evens)
  oc = collections.Counter(odds)
  m = n//2
  
  ans = 0
  em = ec.most_common()
  om = oc.most_common()
  if em[0][0] == om[0][0]:
    p1 = m-em[0][1] + m-om[1][1]
    p2 = m-em[1][1] + m-om[0][1]
    print((min(p1,p2)))
  else:
    print((m-em[0][1] + m-om[0][1]))
  
def input_list():
  return list(map(int, input().split()))

def input_list_str():
  return list(map(str, input().split()))

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

# 2で割り切れる回数
def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c 

import math
import fractions
import collections
from functools import reduce
main()

# Optimized solution
import math
import fractions
from functools import reduce


def main():
    n = int(eval(input()))
    a = input_list()
    if len(set(a)) == 1:
        print((n//2))
        exit(0)
    evens = {}
    odds = {}
    for i, v in enumerate(a):
        if i % 2 == 0:
            if v in evens:
                evens[v] += 1
            else:
                evens[v] = 1
        else:
            if v in odds:
                odds[v] += 1
            else:
                odds[v] = 1
    if len(evens) == 1 and len(odds) == 1:
        print((0))
        exit(0)

    e = sorted(list(evens.items()), key=lambda x: x[1], reverse=True)
    o = sorted(list(odds.items()), key=lambda x: x[1], reverse=True)
    if e[0][0] != o[0][0]:
        even_ans = (n // 2) - e[0][1]
        odd_ans = (n // 2) if len(o) == 1 else (n // 2) - o[0][1]
        a1 = even_ans+odd_ans

        even_ans = (n // 2) if len(e) == 1 else (n // 2) - e[0][1]
        odd_ans = (n // 2) - o[0][1]
        a2 = even_ans+odd_ans
        print((min(a1, a2)))
    else:
        even_ans = (n // 2) - e[0][1]
        odd_ans = (n // 2) if len(o) == 1 else (n // 2) - o[1][1]
        a1 = even_ans + odd_ans

        even_ans = (n // 2) if len(e) == 1 else (n // 2) - e[1][1]
        odd_ans = (n // 2) - o[0][1]
        a2 = even_ans + odd_ans
        print((min(a1, a2)))

# 6
# 3 1 3 2 4 2

def input_list():
    return list(map(int, input().split()))

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

if __name__ == "__main__":
    main()
# Original solution
import sys
input = sys.stdin.readline
from collections import Counter



def main():
    N = int(eval(input()))
    V = [int(x) for x in input().split()]

    a = []
    b = []
    for i in range(N):
        if i & 1:
            a.append(V[i])
        else:
            b.append(V[i])

    ac = Counter(a)
    bc = Counter(b)

    acm = ac.most_common()
    bcm = bc.most_common()

    if acm[0][0] != bcm[0][0]:
        print((N // 2 - acm[0][1] + N // 2 - bcm[0][1]))
    else:
        ans = float("inf")
        for i in acm:
            if i[0] == bcm[0][0]:
                continue
            ans = min(ans, N // 2 - i[1] + N // 2 - bcm[0][1])

        for j in bcm:
            if acm[0][0] == j[0]:
                continue
            ans = min(ans, N // 2 - j[1] + N // 2 - acm[0][1])
        if ans == float("inf"):
            print((N // 2))
        else:
            print(ans)


if __name__ == '__main__':
    main()



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



def main():
    N = int(eval(input()))
    V = [int(x) for x in input().split()]

    ac = Counter()
    bc = Counter()
    for i in range(N):
        if i & 1:
            ac[V[i]] += 1
        else:
            bc[V[i]] += 1

    acm = ac.most_common()
    bcm = bc.most_common()

    if acm[0][0] != bcm[0][0]:
        print((N // 2 - acm[0][1] + N // 2 - bcm[0][1]))
    else:
        ans = float("inf")
        for i in acm:
            if i[0] == bcm[0][0]:
                continue
            ans = min(ans, N // 2 - i[1] + N // 2 - bcm[0][1])

        for j in bcm:
            if acm[0][0] == j[0]:
                continue
            ans = min(ans, N // 2 - j[1] + N // 2 - acm[0][1])
        if ans == float("inf"):
            print((N // 2))
        else:
            print(ans)


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

n = int(eval(input()))
li = list(map(int,input().split()))
a = [l for i,l in enumerate(li) if i % 2 == 0]
b = [l for i,l in enumerate(li) if i % 2 == 1]
se_a = list(set(a))
se_b = list(set(b))
all_lis = []
for aa in se_a:
    tmp_cnt = len(a) - Counter(a)[aa]
    #print(tmp_cnt,len(a),Counter(a)[aa])
    tmp_list = []
    for bb in se_b:
        if aa == bb:
            continue
        tmp_list.append(tmp_cnt+len(b) - Counter(b)[bb])
    #print(tmp_list)
    all_lis += tmp_list
if all_lis:
    print((min(all_lis)))
else:
    print((len(a)))

# Optimized solution
from collections import Counter
n = int(eval(input()))
li = list(map(int,input().split()))
a = [l for i,l in enumerate(li) if i % 2 == 0]
b = [l for i,l in enumerate(li) if i % 2 == 1]
se_a = list(set(a))
se_b = list(set(b))
if Counter(a).most_common()[0][0] != Counter(b).most_common()[0][0]:
    a_change = len(a) - Counter(a).most_common()[0][1]
    b_change = len(b) - Counter(b).most_common()[0][1]
    print((a_change+b_change))
else:
    if len(se_a) == 1 and len(se_b) == 1:
        print((len(a)))
    else:
        x = len(a) - Counter(a).most_common()[0][1] + len(b) - Counter(b).most_common()[1][1]
        y = len(a) - Counter(a).most_common()[1][1] + len(b) - Counter(b).most_common()[0][1]
        print((min(x,y)))
# Original solution
n = int(eval(input()))
l = list(map(int, input().split()))
a = []
b = []
ca = []
cb = []
for i in range(n // 2):
    a.append(l[i * 2])
    b.append(l[i * 2 + 1])
while (len(a) > 0):
    ca.append([a[0], a.count(a[0])])
    a = [s for s in a if not(s == a[0])]
while (len(b) > 0):
    cb.append([b[0], b.count(b[0])])
    b = [s for s in b if not (s == b[0])]
ca.sort(key=lambda x: x[1], reverse=True)
cb.sort(key=lambda x: x[1], reverse=True)
ca_max = ca[0]
cb_max = cb[0]
ca_max_num = ca[0][1]
cb_max_num = cb[0][1]
if ca_max[0] == cb_max[0]:
    if ca_max[1] > cb_max[1]:
        if len(cb) > 1:
            cb_max_num = cb[1][1]
        else:
            cb_max_num = 0
    else:
        if len(ca) > 1:
            ca_max_num = ca[1][1]
        else:
            ca_max_num = 0
print(((n // 2) * 2 - ca_max_num - cb_max_num))

# Optimized solution
n = int(eval(input()))
l = list(map(int, input().split()))
a = {}
b = {}
for i in range(n // 2):
    key_a = l[i * 2]
    key_b = l[i * 2 + 1]
    if key_a in a:
        a[key_a] = a[key_a] + 1
    else:
        a[l[i * 2]] = 1
    if key_b in b:
        b[key_b] = b[key_b] + 1
    else:
        b[key_b] = 1
a = sorted(list(a.items()), key=lambda x: x[1], reverse=True)
b = sorted(list(b.items()), key=lambda x: x[1], reverse=True)
# a = list(a.items())
# b = list(b.items())
# print(a)
# print(b)
ca_max = a[0][0]
cb_max = b[0][0]
ca_max_num = a[0][1]
cb_max_num = b[0][1]
same_num = ca_max_num + cb_max_num
if ca_max == cb_max:
    if len(a) > 1:
        next_ca_max = a[1][1]
    else:
        next_ca_max = 0
    if len(b) > 1:
        next_cb_max = b[1][1]
    else:
        next_cb_max = 0
    same_num = max(ca_max_num + next_cb_max, cb_max_num + next_ca_max)
print((n - same_num))
# Original solution
n = int(eval(input()))
l = list(map(int, input().split()))
a = {}
b = {}
for i in range(n // 2):
    key_a = l[i * 2]
    key_b = l[i * 2 + 1]
    if key_a in a:
        a[key_a] = a[key_a] + 1
    else:
        a[l[i * 2]] = 1
    if key_b in b:
        b[key_b] = b[key_b] + 1
    else:
        b[key_b] = 1
a = sorted(list(a.items()), key=lambda x: x[1], reverse=True)
b = sorted(list(b.items()), key=lambda x: x[1], reverse=True)
# a = list(a.items())
# b = list(b.items())
# print(a)
# print(b)
ca_max = a[0][0]
cb_max = b[0][0]
ca_max_num = a[0][1]
cb_max_num = b[0][1]
same_num = ca_max_num + cb_max_num
if ca_max == cb_max:
    if len(a) > 1:
        next_ca_max = a[1][1]
    else:
        next_ca_max = 0
    if len(b) > 1:
        next_cb_max = b[1][1]
    else:
        next_cb_max = 0
    same_num = max(ca_max_num + next_cb_max, cb_max_num + next_ca_max)
print((n - same_num))

# Optimized solution
n = int(eval(input()))
l = list(map(int, input().split()))
a = {}
b = {}
for i in range(n // 2):
    key_a = l[i * 2]
    key_b = l[i * 2 + 1]
    if key_a in a:
        a[key_a] = a[key_a] + 1
    else:
        a[l[i * 2]] = 1
    if key_b in b:
        b[key_b] = b[key_b] + 1
    else:
        b[key_b] = 1
a = sorted(list(a.items()), key=lambda x: x[1], reverse=True)
b = sorted(list(b.items()), key=lambda x: x[1], reverse=True)
ca_max = a[0][0]
cb_max = b[0][0]
ca_max_num = a[0][1]
cb_max_num = b[0][1]
same_num = ca_max_num + cb_max_num
if ca_max == cb_max:
    if len(a) > 1:
        next_ca_max = a[1][1]
    else:
        next_ca_max = 0
    if len(b) > 1:
        next_cb_max = b[1][1]
    else:
        next_cb_max = 0
    same_num = max(ca_max_num + next_cb_max, cb_max_num + next_ca_max)
print((n - same_num))