Problem:
 Score : 400 points    Problem Statement Snuke has decided to play a game using cards.
He has a deck consisting of N cards. On the i -th card from the top, an integer A_i is written.  He will perform the operation described below zero or more times, so that the values written on the remaining cards will be pairwise distinct. Find the maximum possible number of remaining cards. Here, N is odd, which guarantees that at least one card can be kept.  Operation: Take out three arbitrary cards from the deck. Among those three cards, eat two: one with the largest value, and another with the smallest value. Then, return the remaining one card to the deck.      Constraints  3 ≦ N ≦ 10^{5}  N is odd.  1 ≦ A_i ≦ 10^{5}  A_i is an integer.         Input The input is given from Standard Input in the following format:  N  A_1  A_2  A_3 ... A_{N}       Output Print the answer.        Sample Input 1 5
1 2 1 3 7      Sample Output 1 3  One optimal solution is to perform the operation once, taking out two cards with 1 and one card with 2 . One card with 1 and another with 2 will be eaten, and the remaining card with 1 will be returned to deck. Then, the values written on the remaining cards in the deck will be pairwise distinct: 1 , 3 and 7 .       Sample Input 2 15
1 3 5 2 1 3 2 8 8 6 2 6 11 1 1      Sample Output 2 7

Solution (Python):
n = int(input())
alst = list(map(int, input().split()))
alst.sort()
bef = -1
ans = n
for num in alst:
    if bef == num:
        ans -= 1
    bef = num
if ans % 2 == 1:
    print(ans)
else:
    print(ans - 1)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
from decimal import *



N = INT()
A = LIST()

n = len(set(A))

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
from decimal import *



N = INT()
A = LIST()

C = Counter(A)

key = sorted(C.keys())  

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

Solution (Python):


import sys
read = sys.stdin.read
readline = sys.stdin.readline

n,*a = map(int,read().split())

from collections import Counter

d = Counter(a)

kind = 0
x = 0
for k,v in d.items():
    x += v-1
    kind += 1



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

Solution (Python):

import sys


def solve(N: int, A: "List[int]"):
    
    M = N - len(set(A))
    if M % 2:
        M += 1
    return N - M



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = [int(next(tokens)) for _ in range(N)]  
    print(solve(N, A))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    
    main()

Solution (Python):
import collections
n = int(input())
a = list(map(int,input().split()))
b = list(set(a))
c = collections.Counter(a)
ans = 0
for i in range(len(b)):
    if c[b[i]] >= 2:
        ans += c[b[i]] - 1
print(n-2*(-(-ans//2)))

Solution (Python):
import sys
from collections import Counter

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = list(map(int, input().split()))

    D = Counter(A)
    ev = 0
    for k, v in D.items():
        if v % 2 == 0:
            ev += 1

    print(len(D) if ev % 2 == 0 else len(D) - 1)


if __name__ == '__main__':
    resolve()

Solution (Python):
import sys
from collections import Counter

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = list(map(int, input().split()))
    D = Counter(A)
    ev = 0
    od = 0
    for k, v in D.items():
        if v % 2 == 0:
            ev += 1
        else:
            od += 1
    if ev % 2 == 0:
        print(ev + od)
    else:
        print(ev + od - 1)


if __name__ == '__main__':
    resolve()

Solution (Python):
N = int(input())
As = list(map(int, input().split()))

from collections import defaultdict
d = defaultdict(int)

for a in As:
    d[a] += 1
cnt = 0
for k in d.keys():
    cnt += d[k] - 1

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

Solution (Python):
from collections import Counter


N = int(input())
A = Counter(map(int, input().split()))
ans = len(A)
print(ans - (ans % 2 == 0))

Solution (Python):
N=int(input())
A=list(map(int,input().split()))

d={}
for a in A:
    if a in d:
        d[a]+=1
    else:
        d[a]=1

double=0
ans=0

for D in d:
    if d[D]%2==0:
        double+=1
    if d[D]>2:
        ans+=(d[D]-1)//2
        d[D]=(d[D]-1)%2+1

ans+=double//2+double%2
print(N-2*ans)

Solution (Python):
from collections import Counter

n = int(input())
A = list(map(int, input().split()))
A.sort()
_max = A[-1]
_min = A[0]
C = Counter(A)
odd = 0
even = 0
for v in C.values():
    if v % 2:
        odd += 1
    else:
        even += 1
ans = odd + (even//2)*2
print(ans)

Solution (Python):
n = int(input())
A = [int(x) for x in input().split()]
LIM = 10**5
freq = [0 for i in range(LIM+1)]

for x in A:
    freq[x] += 1

unique = sum([1 if ct > 0 else 0 for ct in freq])
evens = sum([1 if ct > 0 and ct%2==0 else 0 for ct in freq])
print(unique-(1 if evens%2==1 else 0))

Solution (Python):
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
'''


 
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix
'''
 

def ii(): return int(sys.stdin.readline().rstrip()) 
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) 
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]

def ss(): return sys.stdin.readline().rstrip() 
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) 
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]





n=ii()
arr=limii()

res=Counter(arr)

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

Solution (Python):
import heapq

N = int(input())
A_list = list(map(int, input().split()))
dic = {}

for a in A_list:
    if a in dic.keys():
        dic[a] += 1
    else:
        dic[a] = 1

counts = [-item for k,item in dic.items()]
heapq.heapify(counts)

max_cnt = -counts[0]
while max_cnt > 1:
    item1 = heapq.heappop(counts)
    if -item1 >= 3:
        item1 += 2
        if item1 < 0:
            heapq.heappush(counts, item1)
    else:
        item2 = heapq.heappop(counts)
        item1 += 1
        item2 += 1
        if item1 < 0:
            heapq.heappush(counts, item1)
        if item2 < 0:
            heapq.heappush(counts, item2)

    max_cnt = -counts[0]

res = 0
for v in counts:
    if v < 0:
        res += 1
    else:
        break

print(res)

Solution (Python):
import sys
from collections import Counter

n = int(input())
arr = list(map(int, input().split()))

c = Counter(arr)

c = list(c.values())
c = [x - 1 for x in c if x > 1]

if len(c) == 0:
    print(n)
    sys.exit()

if len(c) == 0:
    print(n - 2 * sum(c))
    sys.exit()

print(n - (sum(c) + 1) // 2 * 2)

Solution (Python):
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
cnt = 0
for v in c.values():
    if v > 1:
        cnt += v - 1
print(len(set(a)) - cnt % 2)

Solution (Python):
from math import ceil
n=int(input())
a=list(map(int,input().split()))
print(ceil(len(set(a))/2)*2-1)

Solution (Python):
from math import ceil
n = int(input())
a = list(map(int, input().split()))
print(ceil(len(set(a)) / 2) * 2 - 1)

Solution (Python):





import math
import sys
import bisect
import heapq  
import collections
from collections import deque

inf = 10**18
mod = 10**9+7

n = int(input())
a = list(map(int, input().split()))
c = collections.Counter(a)
kind = 0
for k,v in c.items():
    if v%2==0:
        kind+=1
if kind%2==0:
    print(len(c))
else:
    print(len(c)-1)

Solution (Python):
import sys
import collections

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007



def main():
	n = int(input())
	
	
	al=lin()
	cc=collections.defaultdict(lambda :0)
	for v in al:
		cc[v]+=1
	num2=0
	num1=0
	for k in cc:
		if cc[k]> 1 and cc[k]%2==1:
			cc[k]=1
			num1+=1
		elif cc[k]>1:
			cc[k]=2
			num2+=1
		else:
			num1+=1
	ret=num1
	if num2 % 2 == 1:
		ret += num2 - 1
	else:
		ret += num2
	return ret
		
	
	

isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		
			
	ret = main()
	if ret is not None:
		print(ret)

Solution (Python):
n = int(input())
import collections
dat = list(map(int, input().split()))
dat.sort()

c = collections.Counter(dat)
keys = c.keys()
keys = list(keys)
keys.sort()
buf = []
for k in keys:
    buf.append( (c[k]-1) % 2)

total = sum(buf)
if total % 2 == 1:
    print(len(buf) - 1)
else:
    print(len(buf))

Solution (Python):
from collections import Counter
n = int(input())
A = list(map(int,input().split()))
D = Counter(A)
ans = 0
cnt = 0
for i in D.values():
    if i % 2 == 0:
        ans += (i-2)//2
        cnt += 1
    else:
        if i == 1:
            continue
        ans += (i-3)//2+1
print(n-ans*2-2*((cnt+1)//2))

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
d=dict()
for i in a:
    if i in d:
        d[i]+=1
    else:
        d[i]=1
p=0
k=0
for i in d.values():
    p+=i//2
    k-=i%2-1
print(n-(p-k//2)*2)

Solution (Python):
n=int(input())

l=set(map(int,input().split()))

if len(l)%2==n%2:
    print(len(l))
else:
    print(len(l)-1)

Solution (Python):
import sys


import math
import collections

import bisect
import itertools
import fractions

import copy
import heapq
import decimal

import queue
import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))





def main():
    n = ni()
    a = na()

    c = collections.Counter(a)

    deleted = 0
    for v in c.values():
        deleted += v - 1

    deleted += deleted % 2
    print(n - deleted)


if __name__ == '__main__':
    main()

Solution (Python):
import sys
def input():
    return sys.stdin.readline()[:-1]

import collections

n = int(input())
a = [int(i) for i in input().split()]

dic = collections.defaultdict(int)
for i in range(n):
    dic[a[i]] += 1

ls = collections.deque()
for i in dic.keys():
    if dic[i] > 1:
        ls.append(i)

ans = n
if len(ls) > 0:

    for i in range(n//2):
        if len(ls) == 1 and dic[ls[0]] == 2:
            ans -= 2
            dic[ls[0]] -= 1
            break
        else:
            if len(ls) == 1:
                dic[ls[0]] -= 2
            else:
                dic[ls[0]] -= 1
                dic[ls[-1]] -= 1
            ans -= 2

        if len(ls) > 1:
            if dic[ls[-1]] <= 1:
                ls.pop()
        if dic[ls[0]] <= 1:
            ls.popleft()

        if len(ls) == 0:
            break
print(ans)

Solution (Python):
from collections import Counter
n = int(input())
c = Counter(map(int, input().split()))
rm_cnt = sum(v-1 for v in c.values())
print(len(c.keys())-(rm_cnt % 2))

Solution (Python):
from collections import Counter
n = int(input())
c = Counter(map(int, input().split()))

rm_cnt = sum(v-1 for v in c.values())
if rm_cnt % 2 == 0:
    print(len(c.keys()))
else:
    print(len(c.keys())-1)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a = set(a)

k = len(a)

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

Solution (Python):
n = int(input())
al = list(map(int, input().split())) 
al = set(al)
if len(al)%2 == 0:
    print(len(al)-1)
else:
    print(len(al))

Solution (Python):
n=int(input())
a=list(map(int,input().split()))

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

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
from collections import Counter
import heapq
cou=Counter(a)
c=[]
for k in cou.keys():
    c.append((-cou[k], k))
heapq.heapify(c)
v1,k1=heapq.heappop(c)
while v1<-1:
    if v1<-2:
        v1+=2
        heapq.heappush(c, (v1,k1))
    else:
        v2,k2=heapq.heappop(c)
        if v2<0:
            v1+=1
            v2+=1
            heapq.heappush(c, (v1,k1))
            heapq.heappush(c, (v2,k2))
    v1,k1=heapq.heappop(c)
    
c.append((v1,k1))
cnt=0
for v,k in c:
    if v==-1:
        cnt+=1
print(cnt)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))

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

Solution (Python):
from collections import defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True 
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
a = inl()
h = defaultdict(int)
for x in a:
    h[x] += 1
    if h[x]==3:
        h[x] = 1
y = sum([1 for x in h if h[x]==2])
print(len(h)-y%2)

Solution (Python):
from collections import Counter

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

a.sort()
cnt = Counter(a)
ans = 0
for k, v in cnt.items():
    if v > 1:
        ans += v - 1

print(len(cnt) - ans % 2)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
di = {}
for i in a:
    if i in di:
        di[i] += 1
    else:
        di[i] = 1
ans = len(di) - sum((i+1)%2 for i in di.values())%2
print(ans)

Solution (Python):
n = int(input())
A = list(map(int, input().split()))
from collections import Counter
import math
c = Counter(A)
most = 0
s = 0
for v in c.values():
    if v > 1:
        s += v - 1
        most = max(most, v-1)
if s // 2 >= most:
    result = n - math.ceil(s / 2)*2
else:
    result = max(n - most * 2, 1)
print(result)

Solution (Python):
import collections
def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    N = Z()
    A = ZZ()
    cnt = collections.Counter(A)
    cc = 0
    for key in cnt.keys():
        if cnt[key]%2 == 0: cc += 1
    num_ele = len(set(A))
    print(num_ele if cc%2 == 0 else num_ele-1)

    return

if __name__ == '__main__':
    main()

Solution (Python):
import collections
n = int(input())
a = list(map(int,input().split()))
c = collections.Counter(a)

p = []
ans = 0
for k,v in c.items():
    ans += 1
    if v != 1:
        p.append([k,v])
p.sort()
lef = 0
rig = len(p)-1

while True:
    if lef == rig:
        if p[lef][1] % 2 == 1:
            print(ans)
            exit()
        elif p[lef][1] % 2 == 0:
            print(ans-1)
            exit()
    elif lef > rig:
        print(ans)
        exit()
    p[lef][1] -= 1
    p[rig][1] -= 1
    if p[lef][1] == 1:
        lef += 1
    if p[rig][1] == 1:
        rig -= 1

Solution (Python):
import sys

def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))

def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]

def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(n=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(n+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, n+1, i): is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]
def prime_factor(n):
    """Return a list of prime factorization numbers of n"""
    res = []
    for i in range(2,int(n**0.5)+1):
        while n%i==0: res.append(i); n //= i
    if n != 1: res.append(n)
    return res

MOD=10**9+7

import itertools as it
import functools as ft
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left

def main():
    n = II()
    aa = MII()
    aa.sort()
    c = Counter(aa)
    v = c.values()
    v = [1 if vi%2==1 else 2 for vi in v]
    v_len = len(v)
    v_2_num = v.count(2)
    if v_2_num%2 == 1:
        v_len -= 1
    print(v_len)



if __name__ == '__main__':
    main()

Solution (Python):
import sys
from collections import Counter

N = int(sys.stdin.readline().strip())
A = map(int, sys.stdin.readline().strip().split())
counter = Counter(A)

even_count = 0
for (n, count) in counter.items():
    if count % 2 == 1:
        N -= count // 2 * 2
        counter[n] = 1
    else:
        N -= count - 2
        counter[n] = 2
        even_count += 1

print(N - (even_count + 1) // 2 * 2 )

Solution (Python):
from collections import Counter
n,*a = map(int,open(0).read().split())
c = Counter(a)
b = 0
for i in c.values():
  b+=i-1
if b%2 != 0:
  b+=1
print(n-b)

Solution (Python):
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
A_C = Counter(A)
c = 0
A_C_A = {}
Memo = []
for key, value in A_C.items():
    if value % 2 == 0:
        c += 1
        A_C_A[key] = 2
        if len(Memo) <= 2:
            Memo.append(key)
    else:
        A_C_A[key] = 1


if c == 2:
    Memo.sort()
    for i in range(Memo[0]+1, Memo[1]):
        if A_C[i] != 0:
            print(len(A_C_A))
            exit()
    print(len(A_C_A)-1)

elif c % 2 == 0:
    print(len(A_C))
else:
    print(len(A_C)-1)

Solution (Python):


from collections import Counter
n = int(input())
nums = [int(i) for i in input().split()]
c = Counter(nums)
even = 0
odd = 0
for v in c.values():
    if v % 2 == 0:
        even += 1
    else:
        odd += 1

ans = even + odd
if even % 2 == 1:
    ans -= 1
print(ans)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from collections import Counter

n, *a = map(int, read().split())
counter = Counter(a).values()
ans = len(counter)
if (sum(counter) - ans) % 2 == 1:
    ans -= 1
print(ans)

Solution (Python):
from collections import Counter
n = int(input())
l = list(map(int,input().split()))


c = dict(Counter(l))
l = len(c)
if l % 2 == 1:
  print(l)
else:
  print(l-1)

Solution (Python):



N = int(input())
A = list(map(int, input().split()))

from collections import Counter

c = Counter(A)

odd = 0
even = 0
for v in c.values():
    if v % 2 == 0:
        even += 1
    else:
        odd += 1

if even % 2 == 0:
    ans = odd + even
else:
    ans = odd + even - 1

print(ans)

Solution (Python):
from collections import Counter

N=int(input())
A=list(map(int,input().split()))
d=dict(Counter(A))
for num in d:
  if d[num]>=3:
    if d[num] %2==0:
      d[num]=2
    else:
      d[num]=1     


niko=0
ikko=0
for i in d:
  if d[i]==2:
    niko +=1
  else:
    ikko +=1


ikko += niko
niko = niko%2


if niko==0:
  print(ikko)
else:
  print(ikko-1)

Solution (Python):
from collections import Counter, deque, OrderedDict













import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():

    N = int(input())
    A = list(map(int, input().split()))

    AA = Counter(A)
    ans = 0
    val = 0
    for k, v in AA.items():
        if v % 2 == 0:
            ans += 1
        else:
            val += 1
    if ans % 2 !=0:
        ans -= 1
    print(val+ans)


resolve()

Solution (Python):
n = int(input())
A = list(map(int, input().split()))

from collections import Counter
c = Counter(A)

num2 = 0
for k, v in c.items():
    if v == 2:
        num2 += 1
    if v >= 3:
        if v % 2 == 0:
            c[k] = 2
            num2 += 1
        else:
            c[k] = 1

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

Solution (Python):


from collections import Counter

N = int(input())
A = list(map(int, input().split()))

c = Counter(A)
ans = 0
even = 0
for v in c.values():
    if v % 2 == 0:
        even += 1
    else:
        ans += 1

if even % 2 == 0:
    ans += even
else:
    ans += even-1


print(ans)

Solution (Python):
import math
import fractions



def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    
    return divisors

def ValueToBits(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

def BitsToValue(arr):
    n = len(arr)
    ans = 0
    for i in range(n):
        ans+= arr[i] * 2**i
    return ans

def ZipArray(a):
    aa = [[a[i],i]for i in range(n)]

    aa.sort(key = lambda x : x[0])
    for i in range(n):
        aa[i][0]=i+1
    aa.sort(key = lambda x : x[1])
    b=[aa[i][0] for i in range(len(a))]
    return b

def ValueToArray10(x, digit):
    ans = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        ans[digit-i-1] = now%10
        now = now //10
    return ans

def Zeros(a,b):
    if(b<=-1):
        return [0 for i in range(a)]
    else:
        return [[0 for i in range(b)] for i in range(a)]

class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i


'''
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 2
N = 10 ** 6 + 2
fact = [1, 1]  
factinv = [1, 1]  
inv = [0, 1]  

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

'''










n = int(input())

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

nums = Zeros(10**5,-1)

for i in a:
    nums[i]+=1
ans=0
num2 = 0
for i in nums:
    if(i%2==1):
        ans+=1
    elif(i!=0):
        num2+=1
        
print(ans + num2 - num2%2)

Solution (Python):
from collections import Counter
n = int(input())
cnt = Counter(list(map(int, input().split())))
cnt_2 = 0
for v in cnt.values():
    if v == 1: continue
    if v % 2: n -= v - 1
    else:
        n -= v - 2
        cnt_2 += 1
print(n-(cnt_2+1)//2*2)

Solution (Python):
if __name__ == '__main__':
    n = int(input())
    a = list(map(int, input().split()))
    uniq_len = len(set(a))
    if uniq_len % 2 == 0:
        print(uniq_len - 1)
    else:
        print(uniq_len)

Solution (Python):
from collections import Counter
n=int(input())
a=Counter(list(map(int,input().split())))
b=len([v for v in a.values() if v%2==0])
ans=len(a)
ans-=1 if b%2==1 else 0
print(ans)

Solution (Python):
n = int(input())
a = [int(i) for i in input().split(" ")]
s = len(set(a))
print(s-1+s%2)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))

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

Solution (Python):
n=int(input())
k=len(set(list(map(int,input().split()))))
print(k-1+k%2)

Solution (Python):
n = int(input())
A = list(map(int,input().split()))
num = set()
cnt = 0
for a in A:
    if a in num:
        cnt += 1
    else:
        num.add(a)
print(len(num) - (cnt&1))

Solution (Python):
import collections
n = int(input())
li = list(map(int,input().split()))


c = collections.Counter(li)



kakutei = 0
count = 0
for dd in c.items():
    kazu = dd[1]
    if kazu % 2 == 0:
        count += 1
    kakutei += 1
print(kakutei - count%2)

Solution (Python):


from collections import Counter

n = int(input())
A = list(map(int, input().split()))

if len(set(A)) == n:
    print(n)
    exit()

cA = Counter(A)

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

Solution (Python):
n=int(input())
a=sorted(list(map(int,input().split())))
num=[]
cnt=0
bef=a[0]
for i in range(n):
    if bef==a[i]:
        cnt+=1
    else:
        num.append(cnt-1)
        bef=a[i]
        cnt=1
    if i==n-1:
        num.append(cnt-1)
s=sum(num)
if s%2==0:
    print(n-s)
else:
    print(n-s-1)

Solution (Python):
N=int(input())
A=list(map(int, input().split()))

B=[0]*(max(A))
for a in A:
    B[a-1]+=1

B=sorted(B, reverse=True)



ans=0
pre=0
for b in B:
    b-=pre
    if b>=2 and b%2==1:
        
        
        pre=0
        b=1
    elif b>=2 and b%2==0:
        
        
        pre=1
        b=1
    elif b<2:
        pre=0
    ans+=b
    
print(ans)

Solution (Python):
import sys
import math  
import bisect  
import queue  


def input():
    return sys.stdin.readline().rstrip()


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

    cnt = {}
    for a in A:
        if a not in cnt:
            cnt[a] = 1
        else:
            cnt[a] += 1

    num_cnt_even = 0
    num_cnt_odd = 0
    for v in cnt.values():
        if v % 2 == 0:
            num_cnt_even += 1
        else:
            num_cnt_odd += 1

    if num_cnt_even % 2 == 0:
        print(num_cnt_even + num_cnt_odd)
    else:
        print(num_cnt_even + num_cnt_odd - 1)


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
a = a + [0]

a.sort(reverse = True)

b = 1
ichi = 0
r = []
for i in range(n):
    if a[i] != a[i+1]:
        if b != 1:
            r.append(b)
        else:
            ichi += 1
        b = 1
    else:
        b += 1

for i in range(len(r)-1):
    if r[i] % 2 == 0:
        r[i] = 1
        r[i+1] -= 1
    else:
        r[i] = 1
        
if r != []:
    if r[-1] % 2 == 0:
        print(ichi + len(r) - 1)
    else:
        print(ichi + len(r))
        
else:
    print(ichi)

Solution (Python):
import collections

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

c = collections.Counter(a)

temp=0
for item in c.keys():
    if c[item]>1:
        temp+=c[item]-1

if temp%2==0:
    print(len(list(c.keys())))
else:
    print(max(len(list(c.keys()))-1,1))

Solution (Python):
N = int(input())

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

cnt = [0 for i in range(100001)]

for x in A:
    cnt[x] += 1

oddOrEven = 0

types = 0

for x in cnt:
    if(x > 0):
        types += 1
        oddOrEven += x

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

Solution (Python):
N = int(input())
A = list(map(int, input().split()))

A.sort()

bucket = [0] * (max(A) + 1)
for el in A:
    bucket[el] += 1


odd = len(list(filter(lambda x: x % 2 == 1, bucket)))

even = len(list(filter(lambda x: x % 2 == 0 and x != 0, bucket)))

print(odd + (even // 2) * 2)

Solution (Python):
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
c = Counter(A)
cnt = 0
for k, v in c.items():
    if v > 1:
        cnt += v - 1

if cnt % 2 == 1:
    cnt += 1
print(N - cnt)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))

lsa = len(set(a))
diff = n - lsa

print(lsa - (diff % 2))

Solution (Python):
n = int(input())
ai = [int(i) for i in input().split()]

ans = len(set(ai))

if ans % 2 == 1:
    print(ans)
else:
    print(ans-1)

Solution (Python):
import collections
N = int(input())
A = map(int, input().split())
c = collections.Counter(A)

neven = nodd = 0
for v in c.values():
    if v % 2 == 1:
        nodd += 1
    else:
        neven += 1

ans = nodd
if neven % 2 == 0:
    ans += neven
else:
    ans += neven - 1
print(ans)

Solution (Python):
import collections
n = int(input())
c = len(collections.Counter(list(map(int,input().split()))))
print(c-(1-c%2))

Solution (Python):
import collections
n = int(input())
c = collections.Counter(list(map(int,input().split())))
z = list(c.values())


ans = 0
for c in z:
    ans +=(1-c%2)

print(len(z)-ans%2)

Solution (Python):




n = int(input())
nums = list(map(int, input().split()))

k = len(set(nums))
print(k if k % 2 == 1 else k-1)

Solution (Python):
n = int(input())
nums = list(map(int, input().split()))




nums.sort()
sequential = 1
before = nums[0]
dup = 0
for i in nums[1:]:
    if i == before:
        sequential += 1
    else:
        dup += sequential - 1
        sequential = 1
    before = i

dup += sequential - 1

print(n - (dup + 1) // 2 * 2)

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
kind=0
c=[]
d=[0]*(10**5)
count=0
for i in range(N):
  if(d[A[i]-1]==0):
    kind+=1
  d[A[i]-1]+=1
for i in range(N):
  if(d[i]>0 and d[i]%2==0):
    count+=1
print(kind-(kind+1)%2)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
d = {}
for a in A:
  if a in d:
    d[a] += 1
  else:
    d[a] = 1
print(len(d)-(N-len(d))%2)

Solution (Python):
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
ac = Counter(a).most_common()
ans = len(ac)
if (n-ans)%2 == 0:
    print(ans)
else:
    print(ans-1)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from collections import Counter
from math import ceil

n = int(readline())
a = list(map(int, readline().split()))
counter = Counter(a).values()
cnt = sum(counter) - len(counter)
print(n - ceil(cnt / 2) * 2)