Snuke wants to play a card game with a deck of N cards, each labeled with an integer Ai. He can repeat an operation to remove three cards, eat the highest and lowest value cards, and return the remaining card to the deck. The goal is to find the maximum number of remaining cards with distinct values. Constraints: 3 ≤ N ≤ 10^5, N is odd, 1 ≤ Ai ≤ 10^5. Input format: N followed by N integers. Output: Print the answer. Example: Input 1: 5 1 2 1 3 7, Output 1: 3. Example: Input 2: 15 1 3 5 2 1 3 2 8 8 6 2 6 11 1 1, Output 2: 7.

# Buggy version:
from collections import defaultdict
n = int(input())
a_list = [int(x) for x in input().split()]
d = defaultdict(int)
for a in a_list:
    d[a] += 1
print(len(d.keys()) - sum([v % 2 for v in d.values()]) % 2)

# Fixed version:
from collections import defaultdict
n = int(input())
a_list = [int(x) for x in input().split()]
d = defaultdict(int)
for a in a_list:
    d[a] += 1
print(len(d.keys()) - sum([1 for v in d.values() if v % 2 == 0]) % 2)

# Buggy version:
import sys
import math
N = int(input())
array = list(map(int,input().split()))
set_array = set(array)

if not ( 3 <= N <= 10**5 and N % 2 == 1 ): sys.exit()
if len(array) == len(list(set_array)): print(0);sys.exit()

print(len(list(set_array))) if len(list(set_array) % 2 == 1 else print(len(list(set_array) - 1)

# Fixed version:
import sys
import math
N = int(input())
array = list(map(int,input().split()))
set_array = set(array)

if not ( 3 <= N <= 10**5 and N % 2 == 1 ): sys.exit()

print(len(list(set_array))) if len(list(set_array)) % 2 == 1 else print(len(list(set_array)) - 1)

# Buggy version:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))

#a = Counter(A)
l_a = len(a)
if(l_a%2 == 0):
     print(l_a-1)
else:
    print(l_a)

# Fixed version:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))

a = Counter(A)
l_a = len(a)
if(l_a%2 == 0):
     print(l_a-1)
else:
    print(l_a)

# Buggy version:
#D
import collections
N = int(input())
A = list(map(int,input().split()))
c = collections.Counter(A)
most = c.most_common()
ans = len(most)
eaten = 0
for t in most:
    if t[1] != 1:
        eaten += t[1]-1
if eaten%2 == 1:
    print(ans-2)
else:
    print(ans)

# Fixed version:
#D
import collections
N = int(input())
A = list(map(int,input().split()))
c = collections.Counter(A)
most = c.most_common()
ans = len(most)
eaten = 0
for t in most:
    if t[1] != 1:
        eaten += t[1]-1
if eaten%2 == 1:
    print(ans-1)
else:
    print(ans)

# Buggy version:
n=int(input())
a=list(map(int,input().split()))
d=[0]*(10**5+1)
sa=set(a)
for i in a:
  d[i]+=1
for j in range(len(d)):
  if d[j]>2 and d[j]%2==0:
    d[j]=2
  elif d[j]>2 and d[j]%2!=0:
    d[j]=1
iti=d.count(1)
dsum=sum(d)-iti
if dsum%2==0:
  print(len(sa))
else:
  print(len(sa)-1)

# Fixed version:
n=int(input())
a=list(map(int,input().split()))
d=[0]*(10**5+1)
sa=set(a)
for i in a:
  d[i]+=1
for j in range(len(d)):
  if d[j]>2 and d[j]%2==0:
    d[j]=2
  elif d[j]>2 and d[j]%2!=0:
    d[j]=1
ni=d.count(2)
if ni%2==0:
  print(len(sa))
else:
  print(len(sa)-1)

# Buggy version:
from sys import stdin
from collections import Counter
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
s = len(set(A))
if s % 2 == 0:
    print(s)
else:
    print(s-1)

# Fixed version:
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
s = len(set(A))
if s % 2 != 0:
    print(s)
else:
    print(s-1)

# Buggy version:
n = int(input())
a = set(map, input().split())
ans = len(a) if len(a)%2 == n%2 else len(a)-1
print(ans)

# Fixed version:
n = int(input())
a = set(map(int,input().split()))
ans = len(a) if len(a)%2 == n%2 else len(a)-1
print(ans)

# Buggy version:
N=int(input())
h=[]
a=list(map(int,input().split()))
cnt_dic=defaultdict(int)
for i in range(N):
  cnt_dic[a[i]]+=1
cnt_l=sorted(cnt_dic.values(),reverse=True)
ans=len(cnt_l)
tmp=0
for i in range(ans):
  if cnt_l[i]%2==0:
    tmp+=1
if tmp%2==0:
  pass
else:
  ans-=1
print(ans)

# Fixed version:
from collections import defaultdict
N=int(input())
h=[]
a=list(map(int,input().split()))
cnt_dic=defaultdict(int)
for i in range(N):
  cnt_dic[a[i]]+=1
cnt_l=sorted(cnt_dic.values(),reverse=True)
ans=len(cnt_l)
tmp=0
for i in range(ans):
  if cnt_l[i]%2==0:
    tmp+=1
if tmp%2==0:
  pass
else:
  ans-=1
print(ans)

# Buggy version:
from collections import Counter
from operator import itemgetter
N = int(input())
A = Counter(map(int, input().split()))
ans = 0
left = 0
for k, v in sorted(A.items(), key=itemgetter(1))[::-1]:
    print(k, v, left, ans)
    if left == 1:
        if v == 1:
            ans += 1
            left = 0
            continue
        else:
            v -= 1
            ans += 1
            left = 0
    if v > 3:
        v = v%2 + 2

    if v == 1:
        ans += 1
    elif v == 2:
        left += 1
    elif v == 3:
        ans += 1

print(ans)


# Fixed version:
from collections import Counter
from operator import itemgetter
N = int(input())
A = Counter(map(int, input().split()))
ans = 0
left = 0
for k, v in sorted(A.items(), key=itemgetter(1))[::-1]:
    if left == 1:
        if v == 1:
            ans += 1
            left = 0
            continue
        else:
            v -= 1
            ans += 1
            left = 0
    if v > 3:
        v = v%2 + 2

    if v == 1:
        ans += 1
    elif v == 2:
        left += 1
    elif v == 3:
        ans += 1

print(ans)

# Buggy version:
n = int(input())

a = map(int, input().split())

kind = len(set(a))

if kind % 2 == 0:
  print(kind - 1)
else:
  print(kin)
  

# Fixed version:
n = int(input())

a = map(int, input().split())

kind = len(set(a))

if kind % 2 == 0:
  print(kind - 1)
else:
  print(kind)

# Buggy version:
n=int(input())
a=set(map(int,input().split()))
k=len(a)
#少なくともn-k枚減らす
if n-k % 2 == 0:
  print(k)
else:
  print(k-1)

# Fixed version:
n=int(input())
a=set(map(int,input().split()))
k=len(a)
#少なくともn-k枚減らす
if (n-k) % 2 == 0:
  print(k)
else:
  print(k-1)

# Buggy version:
N = int(input())
A = list(map(int, input().split()))
D = {}
for a in A:
    if a not in D: D[a] = 0
    D[a] += 1

n2 = 0
for k in D:
    D[k] = 2 if D[k]%2==0 else 1
    if D[k]==2: n2+=1

print(len(D) + n2%2)

# Fixed version:
N = int(input())
A = list(map(int, input().split()))
D = {}
for a in A:
    if a not in D: D[a] = 0
    D[a] += 1

n2 = 0
for k in D:
    D[k] = 2 if D[k]%2==0 else 1
    if D[k]==2: n2+=1

print(len(D) - n2%2)

# Buggy version:
#1,1,1 -> (1,1) 1

#1,2,3 -> (1,3) 2

#1,1,3 -> (1,3) 1  <=> 1,1,3,3 -> (1,3) 1,3

#1,2,1,3,7 == [1:2, 2:1, 3:1, 7:1]
#[1:4, 2:3, 3:2, 5:1, 6:2, 8:2, 11:1]

#それぞれ1または2と等しい
#[1:2, 2:1, 3:2, 5:1, 6:2, 8:2, 11:1]
#[1,1,3,3,6,6,8,8]
#[1,1,3,6,6,8,8]
#[1,3,6,8]

N = int(input())
A = list(map(int, input().split()))
B = [-1 for i in range(100005)]

for i in range(N):
    if B[A[i]] == -1:
        B[A[i]] = 1
    elif B[A[i]] == 1:
        B[A[i]] = 2:
    elif B[A[i]] == 2:
        B[A[i]] = 1

n = N - B.count(-1)

if B.count(2) % 2 == 0:
    print(n)
else:
    print(n-1)


# Fixed version:
#1,1,1 -> (1,1) 1

#1,2,3 -> (1,3) 2

#1,1,3 -> (1,3) 1  <=> 1,1,3,3 -> (1,3) 1,3

#1,2,1,3,7 == [1:2, 2:1, 3:1, 7:1]
#[1:4, 2:3, 3:2, 5:1, 6:2, 8:2, 11:1]

#それぞれ1または2と等しい
#[1:2, 2:1, 3:2, 5:1, 6:2, 8:2, 11:1]
#[1,1,3,3,6,6,8,8]
#[1,1,3,6,6,8,8]
#[1,3,6,8]

N = int(input())
A = list(map(int, input().split()))
B = [-1 for i in range(100005)]

for i in range(N):
    if B[A[i]] == -1:
        B[A[i]] = 1
    elif B[A[i]] == 1:
        B[A[i]] = 2
    elif B[A[i]] == 2:
        B[A[i]] = 1

n = len(B) - B.count(-1)

if B.count(2) % 2 == 0:
    print(n)
else:
    print(n-1)

# Buggy version:
n=int(input())
a=list(map(int,input().split()))
i=len(a)
s=set(a)
j=len(s)

if (i-j)%2==0:
  print((i-j)//2)
else:
  print((i-j)//2+1)

# Fixed version:
n=int(input())
a=list(map(int,input().split()))
i=len(a)
s=set(a)
j=len(s)
if (i-j)%2==0:
  print(n-(i-j))
else:
  print(n-(i-j+1))

# Buggy version:
import collections

n = int(input())
l = list(map(int, input().split()))
l = collections.Counter(l)
if n%2==0:
    print(len(l.keys()))
else:
    print(len(l.keys())-1)

# Fixed version:
import collections

n = int(input())
l = list(map(int, input().split()))
l = collections.Counter(l)
kind = len(l.keys())
if (n-kind)%2==0:
    print(len(l.keys()))
else:
    print(len(l.keys())-1)

# Buggy version:
from collections import Counter


def solve(N, As):
    print(N, ",", As)
    counter = Counter(As)
    if len(counter) % 2 == 0:
        return len(counter) - 1
    return len(counter)

if __name__ == "__main__":
    N = int(input())
    As = list(map(int, input().split(" ")))
    print(solve(N, As))


# Fixed version:
from collections import Counter


def solve(N, As):
    counter = Counter(As)
    if len(counter) % 2 == 0:
        return len(counter) - 1
    return len(counter)

if __name__ == "__main__":
    N = int(input())
    As = list(map(int, input().split(" ")))
    print(solve(N, As))

# Buggy version:
x=int(input())
a=list(map(int,input().split()))

b=list(set(a))
y=len(b)

print(x-y-y%2)


# Fixed version:
x=int(input())
a=list(map(int,input().split()))

b=list(set(a))
y=len(b)

print(x-(x-y)-(x-y)%2)

# Buggy version:
input()
a = list(map(int, input().split()))
c = {}
lb = lc = 0
for i in a:
  try:
    c[i] += 1
    lb += 1
  except:
    c[i] = 1
    lc += 1
print(c)
print(lc if lb % 2 == 0 else lc-1)

# Fixed version:
input()
a = list(map(int, input().split()))
c = {}
lb = lc = 0
for i in a:
  try:
    c[i] += 1
    lb += 1
  except:
    c[i] = 1
    lc += 1
print(lc if lb % 2 == 0 else lc-1)

# Buggy version:
n=int(input())
a=list(input().split())
ans=len(set(a))
if ans%2==0:
    ans-1
print(ans)

# Fixed version:
n=int(input())
a=list(input().split())
ans=len(set(a))
if ans%2 == 0:
    ans -= 1
print(ans)

# Buggy version:
n=int(input())
a=list(map(int,input().split()))
b=set(a)
print(len(b) if len(b)%2==0 else len(b)-1)

# Fixed version:
n = int(input())
a = len(set(map(int, input().split())))
print(a if (n-a) % 2 == 0 else a-1)

# Buggy version:
n = int(input())
a = list(map(int, input().split()))
if len(a) % 2 == 1:
    print(len(list(set(a))))
else:
    print(len(list(set(a))) - 1)


# Fixed version:
n = int(input())
a = list(map(int,input().split()))


s = len(a) -len(set(a))
if s%2 == 1:
    print(len(set(a))-1)
else:
    print(len(set(a)))

# Buggy version:
N=int(input())
A=list(map(int,input().split()))
m=set(A)
if m%2==0:
  print(m-1)
else:
  print(m)

# Fixed version:
N = int(input())

A = len(set(list(map(int, input().split()))))

if A % 2 == 0:
    print(A - 1)
else:
    print(A)

# Buggy version:
N=int(input())

A = list(map(int, input().split()))
if len(A)-len(set(A))%2==1:
  print(len(set(A))-1)
else:
  print(len(set(A)))

# Fixed version:
N = int(input())
A = list(map(int, input().split()))
setA = set(A)
if len(setA) % 2 != 0:
    print(len(setA))
else:
    print(len(setA) - 1)

# Buggy version:
N = int(input())
A = input()
list_A = A.split()
set_A = set(list_A)
 i = 0
for a in list_A:
  if a in set_A:
    i += 1
  i = i - len(set_A)
  if i % 2 == 0:
    print(N - i)
  else:
    print(N - (i +1))

# Fixed version:
N = int(input())
A = input()
list_A = A.split()
set_A = set(list_A)
i = 0

for a in list_A:
    if a in set_A:
        i += 1
        
i = i - len(set_A)
if i % 2 == 0:
    print(N - i)
else:
    print(N - (i +1))

# Buggy version:
n = int(input())
a = list(map(int, input().split()))
a_set = set(a)
if len(a) % 2 == 0:
    print(len(a_set) - 1)
else:
    print(len(a_set))


# Fixed version:
n = int(input())
a = list(map(int, input().split()))
a_set = set(a)

if len(a_set) % 2 == 0:
    print(len(a_set) - 1)
else:
    print(len(a_set))

# Buggy version:
import collections
n = int(input())
a_list = [int(i) for i in input().split()]
#まず、奇数個存在する数字を除去
cnt = collections.Counter(a_list)

for key, num in cnt.items():
    print(cnt)
    if num == 2 or num == 1:
        pass
    # 1より大きい奇数なら
    elif num % 2 != 0 and num > 1:
        cnt[key] = 1
        # num = 1
    # 2より大きい偶数なら
    elif num % 2 == 0 and num > 2:
        cnt[key] = 2
        # num = 2
    else:
        pass
        # print("?")

c = 0
result = 0
for key, num in cnt.items():
    if num == 2:
        c += 1

if c % 2 == 0:
    result = len(cnt)
else:
    result = len(cnt) - 1

print(result)

# print("final:",cnt)


# Fixed version:
import collections
n = int(input())
a_list = [int(i) for i in input().split()]
#まず、奇数個存在する数字を除去
cnt = collections.Counter(a_list)
c = 0
for key, num in cnt.items():
    # print(cnt)
    if num == 2 or num == 1:
        if num == 2:
            c += 1
        pass
    # 1より大きい奇数なら
    elif num % 2 != 0 and num > 1:
        cnt[key] = 1
        # num = 1
    # 2より大きい偶数なら
    elif num % 2 == 0 and num > 2:
        c += 1
        cnt[key] = 2
        # num = 2
    else:
        pass
        # print("?")


result = 0
# for key, num in cnt.items():
#     if num == 2:
#         c += 1

if c % 2 == 0:
    result = len(cnt)
else:
    result = len(cnt) - 1

print(result)

# print("final:",cnt)