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())
ar = list(map(int, input().split()))
count = {}
for val in ar:
    if val not in count:
        count[val] = 1
    else:
        count[val] += 1
ones = 0
twos = 0
for val in count:
    if count[val] % 2 == 0:
        twos += 1
    else:
        ones += 1
if twos % 2 == 0:
    print(ones + twos)
else:
    print(ones + twos - 1)

Solution (Python):
n=int(input())
l=sorted(list(map(int,input().split())))
variety=0
countodd=0
counteven=0
countnow=1
now=l[0]
for i in range(1,n):
  if l[i]==now:
    countnow+=1
  else:
    now=l[i]
    if countnow%2==1:
      countodd+=1
    else:
      counteven+=1
    countnow=1
if countnow!=0:
  if countnow%2==1:
    countodd+=1
  else:
    counteven+=1
if counteven%2==0:
  print(counteven+countodd)
else:
  print(counteven+countodd-1)

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

num = [0] * (10**5+1)
for i in a:
    num[i] += 1

a = [i for i in num if i != 0]
ans = N
for i in range(len(a)):
    eat = (a[i]-1) // 2
    a[i] -= eat * 2
    ans -= eat * 2

ans -= a.count(2)//2 * 2
if a.count(2) % 2 == 1:
    ans -= 2
print(ans)

Solution (Python):
import sys
input=sys.stdin.readline

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

    D = dict()
    for a in A:
        if a in D:
            D[a] += 1
        else:
            D[a] = 1

    ans = len(D.items())
    e = 0
    for d in D.items():
        if d[1]%2 == 0:
            e += 1
    if e%2 == 1:
        ans -= 1

    print(ans)

if __name__ == '__main__':
    main()

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

rem = 0
for a in c.values():
    rem += a-1

print(len(c) - rem%2)

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

A.sort()

cnt=0
ans=1
for i in range(1,N):
    if A[i-1]==A[i]:
        cnt+=1



if  cnt%2!=0:
    ans=N-(cnt+1)
else:
    ans=N-cnt

print(ans)

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

A.sort()

cnt=0
ans=1
for i in range(1,N):
    if A[i-1]==A[i]:
        cnt+=1
    else:
        ans+=1


if  cnt%2!=0:
    ans-=1

print(ans)

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

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



sets={}
for i in A:
    if i in sets:
        sets[i]+=1
    else:
        sets[i]=1

duplicate=0
for k,v in sets.items():
    if v>1:
        duplicate+=(v-1)

duplicate %=2

print(len(set(A))-duplicate)

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

import collections
def counter_list(A):
  counter = collections.Counter(A)
  counter =  [list(e) for e in counter.items()]
  
  return counter





A = counter_list(A)
counter2 = 0 
for i in range(len(A)):
  if(A[i][1]%2 == 1): A[i][1] = 1
  elif(A[i][1]%2 == 0): A[i][1] = 2
  if(A[i][1] == 2): counter2 += 1
    
if(counter2 % 2 == 0): ans = len(A)
elif(counter2 %2 == 1): ans = len(A)-1
print(ans)

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

Solution (Python):
from sys import stdin
N = int(stdin.readline().rstrip())
A = set([int(_) for _ in stdin.readline().rstrip().split()])
if len(A) % 2 == 0:
    print(len(A)-1)
else:
    print(len(A))

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

k = len(collections.Counter(a))

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

Solution (Python):
import collections

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

A=list(collections.Counter(A).items())

ans=len(A)


tmp=0
for a in A:
  tmp+=1 if a[1]%2==0 else 0
ans-=1 if tmp%2 else 0

print(ans)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
A.sort()
setA = set(A)
cnt = len(A) - len(set(A))
if cnt % 2 == 0:
    print(len(setA))
else:
    print(len(setA)-1)

Solution (Python):
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
c=Counter(a)
mina=min(a)
maxa=max(a)
d=sum([x-1 for x in c.values() if x>1])
ans=n-2*max((d+1)//2,(c[mina]-1)//2,(c[maxa]-1)//2)
print(ans)

Solution (Python):
from collections import Counter

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

cv = Counter(a).values()
lv = len(cv)

print(lv if not (sum(cv) - lv) % 2 else lv - 1)

Solution (Python):
"""
自分のみを選択することで

3　- 1
4  - 2
5 -3 -1
6 -4 -2
みたいな感じにできるので実質カードは1か2
で2のやつどうしを組み合わせると2つずつ減ってくので、
2の数字の数-2*k,していって
1 - 1
3 -1
2 2
4 -2
みたいな感じになる。

2のやつが１つあるときは、巻き添えで他1つが死ぬ
2のやつが２つあるときは、巻き添えで他のが死ぬことはない。

"""

n = input()
arr = list(map(int,input().split()))
odd = 0
even = 0
cards={}

for a in arr:
    if a not in cards:
        cards[a] = 1
    else:
        cards[a]+=1

for key in cards.keys():
    if cards[key]%2 == 0:
        even += 1
    else:
        odd += 1

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

Solution (Python):
N=map(int,input().split())
A=tuple(map(int,input().split()))
l=[0]*(10**5+1)
for i in A:
    l[i]+=1
a=0
t=0
for i in l:
    if i!=0:
        a+=1
        if i%2==0:
            t+=1
if t%2==1:
    a-=1
print(a)

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

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

CK = [k for k in C.keys()]

i = 0
flag = 0
while(i < len(CK)):
  if flag == 0:
    if C[CK[i]] >= 3:
      C[CK[i]] = 2 - (C[CK[i]] % 2)
    elif C[CK[i]] == 2:
      C[CK[i]] -= 1
      flag = 1
      i += 1
    else:
      i += 1
  else:
    if C[CK[i]] >= 2:
      C[CK[i]] -= 1
      flag = 0
    else:
      i += 1
ans = -flag
for val in C.values():
  ans += val
print(ans)

Solution (Python):
from collections import defaultdict
N = int(input())
A = [int(x) for x in input().split()]
di = defaultdict(int)
for a in A:
    di[a]+=1
print(len(di)-(1-len(di)%2))

Solution (Python):
import sys
N = int(input())
A = [int(a) for a in sys.stdin.readline().split()]

dic = {}
for a in A:
  dic[a] = dic.get(a,0) + 1

evenodd = [0,0]
for k in dic:
  evenodd[dic[k]%2] += 1
if evenodd[0]%2==0:
  print(len(dic))
else:
  print(len(dic)-1)

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

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

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
Aset = set(A)
print(N - (N - len(Aset)) - (N - len(Aset)) % 2)

Solution (Python):
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    a = list(map(int, input().split()))

    dic = {}
    tmp = 0
    for i in range(N):
        if a[i] in dic:
            dic[a[i]] += 1
            tmp += 1
        else:
            dic[a[i]] = 1
    
    print(max(0, N - tmp - int(tmp&1)))


if __name__ == "__main__":
    main()

Solution (Python):
import sys
input = sys.stdin.readline
import collections
def main():
    N = int(input())
    a = list(map(int,input().split()))
    l = collections.Counter(a)
    l = list(l.items())
    count = 0
    for i in range(len(l)):
        count += l[i][1]-1

    print(N-(-(-count//2)*2))

if __name__ == "__main__":
    main()

Solution (Python):


from collections import Counter

n=int(input())
C=Counter(list(map(int,input().split())))

even=0
odd=0
ans=len(C)
for k,v in C.items():
    if v>1:
        if v%2:
            odd+=1
        else:
            even+=1

if even%2:
    ans-=1

print(ans)

Solution (Python):
from collections import Counter
n=int(input())
a=[int(i) for i in input().split()]

count=Counter(a)
check=0
for i,j in count.items():
	if j%2==0:
		check+=1
if check%2==0:
	print(len(count))
else:
	print(len(count)-1)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
from collections import Counter
c = Counter(a)
d = dict(c)
ans = 0
cnt = 0
for k, v in d.items():
  if v%2==0:
    d[k] = 2
    cnt += 1
  else:
    d[k] = 1
  ans += 1
if cnt%2==1:
  ans -= 1
print(ans)

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

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

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

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

Solution (Python):
N = int(input())
A = [int(i) for i in input().split()]
C = [0 for i in range(10**5+1)]
for a in A:
    C[a] += 1
s = False
for i in range(1, len(C)):
    if C[i] >= 2:
        if C[i] % 2 == 0:
            s = not s
if s:
    print(len(set(A))-1)
else:
    print(len(set(A)))

Solution (Python):
import sys
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N, = map(int, input().split())
L = [int(v) for v in input().split()]
L.sort()

m = {}

for v in L:
    if m.get(v) == None:
        m[v] = 0
    m[v] += 1

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

Solution (Python):
from collections import Counter
n = int(input())
a = [int(i) for i in input().split()]
k = Counter(a)
b = list(k.values())
b = [1 if bb % 2 == 1 else 2 for bb in b]
over_2 = [bb for bb in b if bb >= 2]
if len(over_2) == 0:
    print(len(b))
elif len(over_2) % 2 == 0:
    print(len(b))
else:
    print(len(b) - 1)

Solution (Python):
import collections
counter = collections.defaultdict(int)
N = int(input())
A = input().split()

count = 0
for x in A:
    counter[x] += 1

for x in counter:
    if counter[x] != 1:
        count += counter[x] - 1

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

Solution (Python):
N = int(input())
A = [int(i) for i in input().split()]

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

Solution (Python):
n = int(input())
an = len({i for i in input().split()})
print(an-1+an%2)

Solution (Python):

def main():
    N = int(input())
    A = tuple(map(int, input().split()))
    ans = len(set(A))
    ans -= (N - ans) % 2
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
_,a=open(0);a=len(set(a.split()));print(a-(a%2<1))

Solution (Python):
from collections import*;n,l=open(0);a=sum(v-1for v in Counter(l.split()).values());print(int(n)-a-(a%2))

Solution (Python):
from collections import Counter

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







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

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
A.sort()
count = 0
for i in range(N-1):
    if A[i] == A[i+1]:
        count += 1
ans = N-2*(-(-count//2))
print(ans)

Solution (Python):
n = int(input())
a = map(int,input().split())
a = set(a)
f = n - len(a)

if f % 2:
	f += 1

print(n - f)

Solution (Python):
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
cnt = 0
for k in c.keys():
    if c[k] % 2 == 0:
        cnt += 1
if cnt % 2:
    print(len(c) - 1)
else:
    print(len(c))

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

Solution (Python):
N = int(input())
dup = N - len(set(map(int, input().split())))
if dup % 2 == 1:
    dup += 1
print(N - dup)

Solution (Python):
from collections import Counter
N = int(input())
A = [int(i) for i in input().split()]
m = Counter(A)
ls = []
for x, y in m.items():
    if y%2 == 0:
        ls.append(x)
if len(ls)%2 == 0:
    print(len(m))
else:
    print(len(m)-1)

Solution (Python):
from collections import Counter
N= int(input())
A = [int(J) for J in input().split()]
C = Counter(A)
d = len(C)
if d%2:print(d)
else:print(d-1)

Solution (Python):
from collections import Counter

N = int(input())
*A, = map(int, input().split())
cnt = Counter(A)
ans = N
duplicates = sorted([(a, d) for a, d in cnt.items() if d > 1], key=lambda x: x[0])
offset = 0
for _, d in duplicates:
    if offset: d -= offset; offset = 0;
    if d == 1: continue
    elif d % 2 == 0: ans -= d; offset = 1;
    else: ans -= d-1
print(ans)

Solution (Python):
n=int(input())
a=[int(i) for i in input().split()]
a.sort()
d={}
for i in a:
    if i in d:
        d[i]+=1
    else:
        d[i]=1

t=[]
for i in d:
    t.append(d[i])
t.sort(reverse=True)
ans=len(t)
chk=0

for i in t:
    i-=1
    if chk==0:
        chk=i%2
    else:
        chk-=i%2
print(ans-chk)

Solution (Python):
def calc(n):
  ret=n
  while ret>=3:
    ret=ret%3+ret//3
  return ret

n=int(input())
arr=list(map(int,input().split()))
cnt=[0]*(10**5+1)
for i in range(n):
  cnt[arr[i]]+=1
cnt1=0
cnt2=0
for i in range(10**5+1):
  tmp=calc(cnt[i])
  if tmp==1:
    cnt1+=1
  elif tmp==2:
    cnt2+=1
if cnt2%2==0:
  print(cnt1+cnt2)
else:
  print(cnt1+cnt2-1)

Solution (Python):
n=int(input())
l=list(map(int,input().split()))
import collections
c=collections.Counter(l)
ans=n
eve=0
c=sorted(c.values(),reverse=True)
for i in c:
    if(i==1):
        break
    if(i%2==0):
        eve+=1
        ans-=i-2
    else:
        ans-=i-1
print(ans+2*(-eve//2))

Solution (Python):
import sys
import numpy as np


def main():
    _ = int(input())
    a = {int(x) for x in input().split()}
    print(len(a) if len(a) % 2 == 1 else len(a) - 1)


main()

Solution (Python):
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


from collections import defaultdict

n = ni()
a = list(li())

dic = defaultdict(int)

for ai in a:
    dic[ai] += 1

ans = 0
evn = 0

for _, cnt in dic.items():
    if cnt % 2:
        ans += 1

    else:
        evn += 1

        if evn == 2:
            ans += 2
            evn = 0

print(ans)

Solution (Python):
N = int(input())
li = [ int(it) for it in input().split() ]

import collections as col
c = col.Counter(li)

s2=0
s1=0

for k,v in c.items():
  if ( v%2==0):
    s2 += 1
  else:
    s1 += 1
if ( s2%2==0):
  print ( s1+s2)
else:
  print ( s1+s2-1)

Solution (Python):
from collections import defaultdict
N=int(input())
A=list(map(int,input().split()))
dict=defaultdict(int)
for i in A:
    dict[i]+=1
ans=0
tmp=0
for i,j in dict.items():
    ans+=1
    if j%2==0:
        tmp+=1
print(ans-(tmp%2))

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

from collections import Counter

c = Counter(A)


ans = 0
dup = 0

for k, v in c.items():
  ans += 1
  dup += (v+1)%2
  
print(ans - dup%2)

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

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

from collections import Counter
count_dict = Counter(A)

check = 0

for i, v in count_dict.items():
    if v >= 3 and v % 2 == 0:
        count_dict[i] = 2
    elif v >= 3 and v % 2 == 1:
        count_dict[i] = 1
    
    if count_dict[i] == 2:
        check += 1
        
if check % 2 == 0:
    print(len(count_dict))
else:
    print(len(count_dict) - 1)

Solution (Python):

"""
D - Card Eater
https://atcoder.jp/contests/arc068/tasks/arc068_b

"""
import sys


from collections import Counter

def solve(N, cards):
    cnt = Counter(cards)
    freq = [1 if v%2 else 2 for k, v in cnt.items()]
    ones = len([1 for f in freq if f == 1])
    twos = len([2 for f in freq if f == 2])
    if twos:
        if twos % 2:
            ones += (twos-1)
        else:
            ones += twos
    return ones


def main(args):
    N = int(input())
    cards = [int(a) for a in input().split()]
    ans = solve(N, cards)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Solution (Python):
from collections import Counter

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

c = Counter(A).values()

ans = len(c)
cnt = 0
for c_i in c:
    if c_i % 2 == 0:
        cnt += 1
cnt %= 2
ans -= cnt
print(ans)

Solution (Python):

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


m = len(set(A))
ans = m - (1 - m % 2)


print(ans)

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

D = {}

for a in A :
    if a not in D :
        D[a] = 1
    else :
        D[a] += 1


odd = 0
even = 0

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

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

print(ans)

Solution (Python):
n=int(input())
A=[int(i) for i in input().split()]
ans=((len(set(A))+1)//2)*2-1
print(ans)

Solution (Python):

import sys
from collections import defaultdict


def solve(N: int, A: "List[int]"):
    L = [0] * (100001)
    for a in A:
        L[a] += 1
        if L[a] >= 3:
            L[a] -= 2
    c = L.count(2)
    p, q = divmod(c, 2)
    res = sum(L) - 2 * (p + q)
    print(res)
    return



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) ]  
    solve(N, A)

if __name__ == '__main__':
    main()

Solution (Python):
from collections import Counter

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

c = Counter(A).items()

res = 0
for num,cnt in c:
    if cnt % 2 == 0:
        res += 1

ans = len(c)
if res % 2 == 1:
    ans -= 1
print(ans)

Solution (Python):
from collections import Counter
n=input()
print((len(Counter(list(map(int,input().split()))).most_common())-1)//2*2+1)

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
a = sorted(a)
d = {}
num = 0
for i in a:
    if i not in d:
        d[i] = 1
        num += 1

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

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

d = dict()

for i in dat:
    if d.__contains__(i):
        d[i]+=1
    else:
        d[i]=1
d = list(d.items())
d.sort()
minus = 0
twos = 0
for num,cnt in d:
    while cnt>2:
        cnt-=2
        minus+=1
    if cnt==2:
        twos += 1
minus += twos//2
if twos%2:
    minus+=1
print(n-minus*2)

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

num = [0] * int(1e5)
for i in A:
    num[i] += 1

need = 0
for i in num:
    need += max(i-1, 0)

if need % 2 == 1:
    need += 1

ans = N - need
print(ans)

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

A.sort()

A.append(0)
B = []
length = 1
for i in range(N):
    if A[i] == A[i+1]:
        length += 1
    else:
        B.append(length)
        length = 1

for i in range(len(B)):
    B[i] = 2 - B[i] % 2

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

Solution (Python):
from collections import Counter
n = int(input())
A = list(map(int,input().split()))
l = len(Counter(A))
if l%2 == 1:
    print(l)
else:
    print(l-1)

Solution (Python):
from collections import Counter

N = int(input())
A = [int(i) for i in input().split()]

sumA = sum([v - 1 for v in Counter(A).values() if v > 1])

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

Solution (Python):
n = int(input())
l = list(input().split())
set = set()
du = 0
for i in range(n):
    if l[i] in set:
        du +=1
    else:
        set.add(l[i])
print(n - du - du%2)

Solution (Python):
import sys
from collections import Counter
sys.setrecursionlimit(10**7)
mo=10**9+7
n=10**5


n=int(input())
x=set()
for i in input().split():
    x.add(int(i))
ans=len(x) - (1 if (n-len(x))%2==1 else 0)

print(ans)

Solution (Python):
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]
    a = f()
    num_diff = len(set(a))
    to_eat = n - num_diff
    if to_eat%2:
        to_eat += 1
    
    print(n - to_eat)
    

solve()

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
A.sort()
def arraycount(arr):
  arr_target = [[]]
  cnt = 1
  for i in range(1,len(arr)):
     if arr[i] == arr[i-1]:
         cnt += 1
     else:
         arr_target.append([arr[i-1],cnt])
         cnt = 1
  arr_target.append([arr[len(arr)-1],cnt])
  del arr_target[0]
  return arr_target
B = arraycount(A)
n = len(B)
for i in range(n):
    if B[i][1] >=3:
        if B[i][1] % 2 == 0:
            B[i][1] = 2
        else:
            B[i][1] = 1
    else:
        continue
cnt,ans =0,0
for i in range(n):
    ans += B[i][1]
    if B[i][1] == 2:
        cnt +=1
ans = ans - 2*(-(-cnt//2))
print(ans)

Solution (Python):


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

a.sort()

cnt = 0
for i in range(1,len(a)):
    if a[i-1] == a[i]:
        cnt += 1

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

Solution (Python):
from functools import reduce
import math

def main():
    
    
    
    
    
    
    
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    
    
    
    
    N = int(input().rstrip())
    A = list(int(_) for _ in input().split())
    dict = {}
    for a in A:
        if a in dict:
            dict[a] += 1
        else:
            dict[a] =1
    sum = 0
    for v in dict.values():
        if v >=2:
           sum += v -1
    if sum%2 == 0:
        ans = len(dict)
    else:
        ans = len(dict) - 1
    print(ans)
    
if __name__ == '__main__':
    main()

Solution (Python):



def main():
    n = int(input())
    a = list(map(int, input().split()))
    count = len((set(a)))

    if count % 2 == 0:
        count -= 1

    print(count)


if __name__ == '__main__':
    main()

Solution (Python):
N=int(input())
A=[int(i) for i in input().split()]

st=set(A)
res = len(st)
if (N-res)%2==0:
    print(res)
else:
    print(res-1)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
d = [0] * 100001
ans = 0
for i in A:
    if d[i] >0:
        ans += 1
    d[i] += 1
print(N - ((ans + 1) // 2) * 2)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
d = [0] * 100001
ans = 0
for i in A:
    if d[i] >0:
        ans += 1
    d[i] += 1
print(N - ((ans + 1) // 2) * 2)

Solution (Python):
from collections import defaultdict
n=int(input())
d=defaultdict(int)
a=list(map(int,input().split()))
for i in range(n):
    d[a[i]]+=1
c=0
for i in d.values():
    c+=i-1
print(n-2*((c+1)//2))

Solution (Python):
n = int(input())
a = set(input().split())
if len(a) % 2:
  print(len(a))
else:
  print(len(a)-1)

Solution (Python):
n = int(input())
lis = list(map(int,input().split()))
ans = set()
for num in lis:ans.add(num)
print(len(ans)-((len(ans) % 2)+1)%2)

Solution (Python):
from collections import defaultdict

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

D = defaultdict(int)
for i in A:
	D[i] += 1

d = []
for i in D:
	d.append(D[i])

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

Solution (Python):
from collections import defaultdict
N=int(input())
A=[int(i) for i in input().split()]
dd=defaultdict(int)
for a in A:
    dd[a]+=1
num=0
s=0
for p,n in dd.items():
    num+=1
    if n%2==0:
        s+=1
        s%=2
print(num-s)

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

adic = {}
for a in alist:
  if a in adic:
    adic[a] += 1
  else:
    adic[a] = 1

res = sum([v-1 for v in adic.values()])
print(n - res - res%2)

Solution (Python):
N = int(input())
L = list(map(int,input().split()))
L.sort()
L.append(0)
EVEN = 0
ODD = 0
cnt = 1
cur = L[0]
i = 0
while i < N:
  if L[i] == L[i+1]:
    cnt += 1
    i += 1
  else:
    if cnt%2 == 0:
      EVEN += 1
    else:
      ODD += 1
    cur = L[i+1]
    i += 1
    cnt = 1
if EVEN%2 == 0:
  print(EVEN+ODD)
else:
  print(EVEN+ODD-1)

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

odd=0
eve =0

for k  in counter.keys():
  if counter[k]%2==0:
    eve+=1
  else:
    odd+=1
ans=0
if eve%2==0:
  ans=eve+odd
else:
  ans=eve+odd-1
print(ans)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
d = {}
for i in a:
    d[i] = d.get(i,0)+1
k = len(d)
k -= (sum(d.values()) - k) % 2
print(k)

Solution (Python):
from collections import Counter


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


N = int(input())
A = inpl()

oe = [0, 0]
for k, v in Counter(A).items():
    oe[v % 2] += 1

if oe[0] % 2 == 0:
    print(sum(oe))
else:
    print(sum(oe) - 1)

Solution (Python):
from collections import Counter

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

ac=Counter(a)
ans=len(ac)
count=0

for aa in ac.values():
    if aa%2==0:
        count+=1


print(ans-(count%2))

Solution (Python):
from collections import Counter

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
Num = list(input().split())
C = Counter(Num)
ans = 0

l = [0]
v = len(C)
odd = len(list(filter(lambda x: x % 2 == 1, C.values())))
even = v - odd
ans += odd + even//2*2
print(ans)

Solution (Python):


def main():
    n = int(input())
    an = list(map(int, input().split()))
    k = len(set(an))
    res = k - 1 if k % 2 == 0 else k
    print(res)

main()

Solution (Python):
N = int(input())
A = [int(i) for i in input().split()]
A.sort()
res = 0
for i in range(N-1):
    if A[i] == A[i+1]:
        res += 1
res = (N - res + 1) // 2 * 2 - 1
print(res)

Solution (Python):
from collections import Counter
N=int(input())
A=list(map(int,input().split()))
Ac=dict(Counter(A))
a=0
b=0
for i in Ac.keys():
    if Ac[i]>1:
        a+=Ac[i]-1
if a%2==0:
    print(N-a)
else:
    print(N-a-1)

Solution (Python):
a = int(input())
ar = list(map(int,input().split(" ")))
br = set(ar)
count = len(ar) - len(br)
if count % 2 == 0:
    print(a - count)
else:
    print(a - count - 1)

Solution (Python):
N=int(input())
A=[int(i) for i in input().split()]
A.sort()
s=A[0]
v=1
l=0
for i in range(1,N):
  if s==A[i]:
    l+=1
  else:
    v+=1
    s=A[i]
print(v-(l%2))

Solution (Python):
def inpl(): return [int(i) for i in input().split()]

N = int(input())
A = inpl()
B = set([])
for i in A:
    B.add(i)
print(len(B)-(len(A)-len(B))%2)

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

count = collections.Counter(a)
rmv = 0

for i in count:
    if count[i] >= 2 and count[i]%2 == 1:
        rmv += (count[i]-1)
        count[i] = 1
    elif count[i] >= 2:
        rmv += (count[i]-2)
        count[i] = 2

two = 0
for i in count:
    if count[i] == 2:
        two += 1
if two%2 == 0:
    rmv += two
else:
    rmv += two+1
print(n-rmv)

Solution (Python):
from collections import Counter

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

cnts = Counter(As)
num = 0
for k in cnts.values():
    if k % 2 == 0:
        num += 1

print(len(cnts.keys()) - num % 2)

Solution (Python):
N = int(input())
eat = N - len(set(map(int, input().split())))
print(N - eat - eat % 2)

Solution (Python):
N = int(input())
f = set()
eat = 0
for a in map(int, input().split()):
    if a in f:
        eat += 1
    else:
        f.add(a)
print(N - eat - eat % 2)

Solution (Python):

n = int(input())
d = {}

for x in input().split():
    x = int(x)
    if x not in d:
        d[x] = 0
    d[x] += 1

cnt = 0
dcnt = 0
for k in d.keys():
    if d[k]%2==1:
        cnt += 1
    else:
        dcnt += 1

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

Solution (Python):
from collections import defaultdict
def getN():
    return int(input())


def getNM():
    return map(int, input().split())


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

N = getN()
nums = getList()
dup = defaultdict(int)

for n in nums:
    dup[n] += 1

poss = len(dup.keys())
dupdup = 0
for val in dup.values():
    if val % 2 == 0:
        dupdup += 1

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

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

B = [0 for i in range(max(A))]
for i in range(len(A)):
    B[A[i]-1]+=1

score=0
res=0
for i in range(len(B)):
    if B[i]>=1:
        score+=1
    if B[i]>=2:
        res+=B[i]-1

if res%2==0:
    print score
else:
    print score-1

Solution (Python):
def ARC068D():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    count_list = []
    cnt = 1
    
    for i in range(1, N):
        if A[i] == A[i - 1]:
            cnt += 1
        else:
            count_list.append(cnt)
            cnt = 1
    count_list.append(cnt)
    ans_cnt = 0
    
    for i in range(len(count_list)):
        if count_list[i] > 2:
            ans_cnt += (count_list[i] % 2) - 1
            count_list[i] %= 2
            if count_list[i] == 0:
                count_list[i] = 2
    
    count_list = sorted(count_list)[::-1]
    for i in range(len(count_list) - 1):
        if count_list[i] == 2 and count_list[i + 1] == 2:
            ans_cnt += 1
            count_list[i] = 1
            count_list[i + 1] = 1
    count_list = sorted(count_list)[::-1]
    if count_list[0] == 2:
        count_list[0] = 0
    
    
    print(sum(count_list))
ARC068D()