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):
from collections import Counter

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

a.sort()
c = Counter(a)

ans = 0
for k, v in c.items():
    ans += v - 1

print(n - (ans % 2 + ans))

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
from collections import defaultdict
cnt=defaultdict(int)
for a in A:
    cnt[a]+=1

twice=0
ans=0
for i,j in cnt.items():
    if j>=2:
        ans+=(j-1)//2
        twice+=(j-1)%2
ans+=(twice+1)//2
print(N-2*ans)

Solution (Python):
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy

def j(q):
    if q==1: print("YES")
    else:print("NO")
    exit(0)


def ct(x,y):
    if (x>y):print("GREATER")
    elif (x<y): print("LESS")
    else: print("EQUAL")

def ip():
    return int(input())
n = ip()                                     

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








b = set(a)
coin = len(a) - len(b)
if coin%2:coin+=1
print(len(a)-coin)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
cnt = [0 for _ in range(max(a))]
for i in range(n):
  cnt[a[i]-1] += 1
ans = 0
d = 0
for i in range(len(cnt)):
  if cnt[i] > 0:
    ans += 1
    if cnt[i] % 2 == 0:
      d += 1
print(ans - d%2)

Solution (Python):

from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007






"""
x = I()
ans = 2*(x//11)+1
x %= 11
if x == 0:
    ans -= 1
if x > 6:
    ans += 1
print(ans)
"""


n = I()
a = LI()
d = defaultdict(int)
for i in a:
    d[i] += 1
l = list(d.values())
k = len(l)+sum(l)
for i in d.keys():
    d[i] = 1
ans = sum(list(d.values()))
ans -= 1 if k%2 else 0
print(ans)

Solution (Python):

from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007






"""
x = I()
ans = 2*(x//11)+1
x %= 11
if x == 0:
    ans -= 1
if x > 6:
    ans += 1
print(ans)
"""


n = I()
a = LI()
d = defaultdict(int)
for i in a:
    d[i] += 1
l = list(d.values())
k = len(l)+sum(l)
for i in d.keys():
    d[i] = 1
ans = sum(list(d.values()))
ans -= 1 if k%2 else 0
print(ans)

Solution (Python):

from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007






"""
x = I()
ans = 2*(x//11)+1
x %= 11
if x == 0:
    ans -= 1
if x > 6:
    ans += 1
print(ans)
"""


n = I()
a = LI()
d = defaultdict(int)
for i in a:
    d[i] += 1
l = list(d.keys())
k = 0
for i in l:
    k ^= ~(d[i]%2)
    d[i] = 1
ans = sum(list(d.values()))
ans -= 1 if k%2 else 0
print(ans)

Solution (Python):

from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007






"""
x = I()
ans = 2*(x//11)+1
x %= 11
if x == 0:
    ans -= 1
if x > 6:
    ans += 1
print(ans)
"""


n = I()
a = LI()
d = defaultdict(int)
for i in a:
    d[i] += 1
l = list(d.keys())
k = 0
for i in l:
    k ^= ~(d[i]%2)
    d[i] = 1
ans = sum(list(d.values()))
ans -= 1 if k%2 else 0
print(ans)

Solution (Python):

from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007






"""
x = I()
ans = 2*(x//11)+1
x %= 11
if x == 0:
    ans -= 1
if x > 6:
    ans += 1
print(ans)
"""


n = I()
a = LI()
d = defaultdict(int)
for i in a:
    d[i] += 1
l = list(d.keys())
i = 0
while i < len(l):
    if d[l[i]] < 2:
        l.pop(i)
        i -= 1
    i += 1
l.sort()
k = 0
for i in l:
    k ^= ~(d[i]%2)
    d[i] = 1
ans = sum(list(d.values()))
ans -= 1 if k%2 else 0
print(ans)

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

a = sorted(a)

info= []
count = 0
for i in range(len(a)-1):
  if a[i+1]==a[i]:
    count +=1
  else:
    if count !=0:
      info.append(count)
    count = 0

if count !=0:
  info.append(count)

print(n-sum(info) if sum(info)%2==0 else n-sum(info)-1)

Solution (Python):
input()
a=len(set(input().split()))
print(a-1+a%2)

Solution (Python):
def fun():
     print('ac')
     print('AC')
     print('ACAC')
     print('ac')
n=eval(input())
ls=map(int,input().split())
l=[]
for i in ls:
     l.append(i)
result=len(set(l))
if result%2==0:
     result-=1
print(result)

Solution (Python):

a = int(input())

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

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

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

COUNT=0
for c in counter:
    if counter[c]>1:
        COUNT+=counter[c]-1


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

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

Solution (Python):
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
C = Counter(A)
ans = len(C)
if (N-ans) % 2 == 1:
    ans -= 1
print(ans)

Solution (Python):
from collections import Counter

n=int(input())
c=Counter(map(int,input().split()))
v=sum(map(lambda x:x-1,c.values()))
if v%2==0:
    print(len(c))
else:
    print(len(c)-1)

Solution (Python):
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))

Solution (Python):
from collections import Counter
n = int(input())
counter = Counter(list(map(int, input().split())))
ans = n
cnt = 0
for v in counter.values():
    if v % 2 == 0:
        if v >= 3:
            ans -= v - 2
        cnt += 1
    else:
        ans -= v - 1

ans -= cnt + cnt % 2
print(ans)

Solution (Python):


import sys
def input(): return sys.stdin.readline().strip()
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

from collections import Counter

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

dups = Counter(aN)
for k, v in dups.items():
    dups[k] -= 1
aN = sorted(set(aN))

if sum(dups.values()) % 2 == 0:
    print(len(aN))
else:
    print(len(aN)-1)

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

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
A = sorted(A)
count = [1]
count_index = 0
for i in range(1, N):
    if A[i] > A[i-1]:
        count.append(1)
        count_index += 1
    else:
        count[count_index] += 1
for i in range(count_index + 1):
    count[i] = 1 - count[i] % 2
print(count_index + 1 - sum(count) % 2)

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

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

ans = len(set(A))
C = Counter(A)
Even = 0
for v in C.values():
    if v % 2 == 0:
        Even += 1

if Even % 2 == 1:
    ans -= 1

print(ans)

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

from collections import Counter

a_set = set(a_list)
counter = Counter(a_list)

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

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

Solution (Python):
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
C = Counter(A).items()
M = len(C)
print(M if (N-M)%2==0 else M-1)

Solution (Python):
N = int(input())
A = [int(_) for _ in input().split()]
count = {}
for a in A:
    count[a] = count.get(a, 0) + 1
res = 0
for k, v in count.items():
    res += v - 1
print(N - 2 * ((res + 1) // 2))

Solution (Python):
import collections
N=int(input())
L=list(map(int,input().split()))
L=sorted(L)
L1=[]
for x in collections.Counter(L).most_common():
    L1.append(list(x))
for x in L1:
    if x[1] > 2 and x[1] % 2 == 0:
        x[1] = 2
    elif x[1] > 2 and x[1] % 2 == 1:
        x[1] = 1
flag = 0
temp = -1
for i in range(len(L1)):
    if L1[i][1] == 2 and flag == 0:
        flag = 1
        temp = i
    elif L1[i][1] == 2 and flag == 1:
        flag = 0
        L1[i][1] = 1
        L1[temp][1] = 1
        temp = -1
for x in L1:
    if x[1] == 2:
        print(len(L1)-1)
        break
else:
    print(len(L1))

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

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

Solution (Python):
import collections

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

con = collections.Counter(A)

ans = len(set(A))

tmp = 0

for i in con.values():
    if i % 2 == 0:
        tmp += 1
        
if tmp % 2 != 0:
    ans -= 1
    
print(ans)

Solution (Python):
import collections
n = int(input())
a = input().split()
a = [int(m) for m in a]
a.sort()
c = collections.Counter(a)
count = 0
for i in c:
    if c[i] % 2 == 0:
        count += 1
if count % 2 == 0:
    print(len(c))
else:
    print(len(c) - 1)

Solution (Python):
import sys
import math
import collections
import itertools
import array
import inspect


sys.setrecursionlimit(1000000)



def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))



def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v



def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk



def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False



dp = None


def main():
    N = int(input())
    A = set(li_input())

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

    



main()

Solution (Python):
n=int(input())
cards=list(map(int,input().split()))
cards.sort()
prevnum=cards[0]
difnum=1
for i in range(n):
    if(cards[i]!=prevnum):
        prevnum=cards[i]
        difnum+=1
if (n-difnum)%2==0:
    print(str(difnum))
else:
    print(str(difnum-1))

Solution (Python):
N=int(input())
dic={}
for x in map(int,input().split()):
    dic[x]=dic.setdefault(x,-1)+1

cnt=0
for x in dic.values():
    if x%2==1:
        cnt+=1

print(len(dic)-cnt%2)

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

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

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

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

cnt = [0]*(int(1e5)+2) 
for ai in A:
    cnt[ai] += 1
    if cnt[ai]==3:
        cnt[ai] -= 2

s = sum(cnt) - ans
s_i = 0

for i in range(1, len(cnt)):
    if cnt[i-1]==2:
        s_i += 1
        s -= 1
    if s_i == s:
        break
else:
    ans -= 1
        
print(ans)

Solution (Python):

from collections import Counter
N = int(input())
A = list(map(int, input().split()))
B = len(Counter(A))
print(B-1 if B%2==0 else B)

Solution (Python):
from collections import Counter
N = int( input())
A = list( map( int, input().split()))
CA = Counter(A)
V = []
for x in CA:
    if CA[x] >= 2:
        V.append(CA[x]-1)
V.sort(key = None, reverse = True)
now = 0
ans = 0
for v in V:
    ans += v
    if now <= 0:
        now += v
    else:
        now -= v
b = abs(now)
if b%2 == 1:
    ans += 1
print( max(0,N-ans))

Solution (Python):
from collections import Counter
N = int( input())
A = list( map( int, input().split()))
CA = Counter(A)
V = []
for x in CA:
    if CA[x] >= 2:
        V.append(CA[x]-1)
V.sort(key = None, reverse = True)
now = 0
ans = 0
for v in V:
    ans += v
    if now <= 0:
        now += v
    else:
        now -= v
b = abs(now)
if b%2 == 1:
    ans += 1
print( N-ans)

Solution (Python):
from collections import Counter
N = int( input())
A = list( map( int, input().split()))
CA = Counter(A)
V = []
for x in CA:
    if CA[x] >= 2:
        V.append(CA[x]-1)
V.sort(key = None, reverse = True)
now = 0
ans = 0
for v in V:
    ans += v
    if now <= 0:
        now += v
    else:
        now -= v
b = abs(now)
if b%2 == 1:
    ans += 1
else:
    pass
print( N-ans)

Solution (Python):
from collections import Counter
N = int( input())
A = list( map( int, input().split()))
CA = Counter(A)
V = []
for x in CA:
    if CA[x] >= 2:
        V.append(CA[x]-1)
V.sort(key = None, reverse = True)
now = 0
ans = 0
for v in V:
    ans += v
    if now <= 0:
        now += v
    else:
        now -= v
b = abs(now)
if b%2 == 1:
    ans += 1
else:
    pass
print( max(N-ans,0))

Solution (Python):
from collections import Counter
N = int( input())
A = list( map( int, input().split()))
CA = Counter(A)
V = []
for x in CA:
    if CA[x] >= 2:
        V.append(CA[x]-1)
V.sort(key = None, reverse = True)
now = 0
ans = 0
for v in V:
    ans += v
    if now <= 0:
        now += v
    else:
        now -= v
b = abs(now)
if b == 0:
    pass
elif b%2 == 1:
    ans += 1
else:
    pass
print( max(N-ans,0))

Solution (Python):
N=int(input())
a=list(map(int,input().split()))
mp={}
cnt=0
for it in a:
    if it in mp:
        cnt+=1
    else :
        mp[it]=1
N-=cnt
while cnt>=3:
    cnt=cnt//3+cnt%3
print(max(N-int(cnt==1),1))

Solution (Python):
N = int(input())
A = [int(a) for a in input().split()]
Card = {}
for i in range(N):
    if A[i] in Card:
        Card[A[i]] += 1
    else:
        Card[A[i]] = 1

rem, double = len(Card), 0
for i in Card:
    if Card[i] % 2 == 0:
        double += 1

print(rem - double % 2)

Solution (Python):
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


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

    t = 0
    for k in C.keys():
        t += (C[k] % 2 == 0)

    ans = len(set(C))
    if t % 2 != 0:
        ans -= 1
    print(ans)


if __name__ == '__main__':
    main()

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

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

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

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

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

l = []
a.sort()

num = 1
for i in range(len(a)-1):
    if a[i+1] == a[i]:
        num += 1
    else:
        l.append(num)
        num = 1
l.append(num)

count = 0
for i in range(len(l)):
    if l[i] % 2 == 1:
        l[i] = 1
    else:
        count += 1
        l[i] = 1

if count % 2 == 0:
    print(sum(l))
else:
    print(sum(l) - 1)

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

l = []
a.sort()

i = 0
num = 1
while i < len(a) - 1:
    if a[i+1] == a[i]:
        num += 1
        i += 1
    else:
        l.append(num)
        num = 1
        i += 1
l.append(num)

count = 0
for i in range(len(l)):
    if l[i] % 2 == 1:
        l[i] = 1
    else:
        count += 1
        l[i] = 1

if count % 2 == 0:
    print(sum(l))
else:
    print(sum(l) - 1)

Solution (Python):
input();a=len(set(input().split()));print(a-1+a%2)

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

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

evennum = len([1 for v in ctr.values() if v%2==0])
if evennum%2:
    print(len(ctr) - 1)
else:
    print(len(ctr))

Solution (Python):

import sys
stdin = sys.stdin

def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())

n = ni()
a = li()

unique = set(a)
doub = len(a) - len(unique)

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

Solution (Python):
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)

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

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

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

Solution (Python):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())


N = int(input())
aa = inpl()
sums = defaultdict(int)
numbers = set()

for a in aa:
	sums[a] += 1

ans = 0
eve = 0
for i in range(1,10**5+3):
	tmp = sums[i]
	if tmp <= 1:
		continue
	else:
		if tmp%2 == 1:
			ans += (tmp-1)//2
		else:
			ans += tmp//2-1
			eve += 1

ans += (eve+1)//2
print(N-ans*2)

Solution (Python):
from collections import Counter

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

num = len(Counter(A))

print(num - (N-num)%2)

Solution (Python):

import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input()


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


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


def warshall_floyd(g):
    d = defaultdict(dict)
    V = list(g.keys())
    for v in g.values():
        V.extend(list(v))
    V = set(V)
    for i in V:
        for j in V:
            if i in g and j in g[i]:
                d[i][j] = g[i][j]
            else:
                d[i][j] = sys.maxsize
    for k in g:
        for i in g:
            for j in g:
                if d[i][j] > d[i][k] + d[k][j]:
                    d[i][j] = d[i][k] + d[k][j]

    return d


@mt
def slv(N, A):
    c = Counter(A)
    ks = list(c.keys())
    ks.sort()

    ans = 0
    for k in ks:
        if c[k] % 2 == 1:
            c.pop(k)
            ans += 1
        else:
            c[k] = 2

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

    return ans


def main():
    N = read_int()
    A = read_int_n()

    print(slv(N, A))


if __name__ == '__main__':
    main()

Solution (Python):

import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input()


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


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


def warshall_floyd(g):
    d = defaultdict(dict)
    V = list(g.keys())
    for v in g.values():
        V.extend(list(v))
    V = set(V)
    for i in V:
        for j in V:
            if i in g and j in g[i]:
                d[i][j] = g[i][j]
            else:
                d[i][j] = sys.maxsize
    for k in g:
        for i in g:
            for j in g:
                if d[i][j] > d[i][k] + d[k][j]:
                    d[i][j] = d[i][k] + d[k][j]

    return d


@mt
def slv(N, A):
    c = Counter(A)
    ks = list(c.keys())
    ks.sort()

    ans = 0
    for k in ks:
        if c[k] % 2 == 1:
            c.pop(k)
            ans += 1
        else:
            c[k] = 2

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

    return ans


def main():
    N = read_int()
    A = read_int_n()

    print(slv(N, A))


if __name__ == '__main__':
    main()

Solution (Python):
s=input()
s=input().split()
s.sort()
cc=s[0]
cnt=1
l=[]
for c in s[1:]:
 if c==cc:
  cnt+=1
 else:
  l.append(cnt%2)
  cnt=1
  cc=c
l.append(cnt%2)
a=-1 if l.count(0)%2==1 else 0
print(len(l)+a)

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

arr = map(int,raw_input().split())
l = len(arr)
counter = collections.Counter(arr)

c = 0

for item in counter.items() :
	if item[1] > 2:
		if item[1] % 2 == 1 :
			l -= item[1] - 1

		else:
			l -= item[1] - 2

	if item[1] % 2 == 0 :
		c += 1

if c % 2 == 0:
	l -= c

else :
	l -= c+1

print l

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

a_n = {}
for i in range(n):
    if a[i] not in a_n.keys():
        a_n[a[i]] = 1
    else:
        a_n[a[i]] += 1

if (n-len(a_n.keys()))%2 == 0:
    print(len(a_n.keys()))
else:
    print(len(a_n.keys())-1)

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

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

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

Solution (Python):
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)

Solution (Python):
N = int(input())
A = map(int, input().split())
d = [0 for i in range(10 ** 5 + 1)]
for a in A:
    d[a] = 1
s = sum(d)
print(s - (0 if s % 2 else 1))

Solution (Python):
import functools
N = int(input())
A = map(int, input().split())
d = [0 for i in range(10 ** 5 + 1)]
for a in A:
    d[a] = 1
s = sum(d)
print(s - (0 if s % 2 else 1))

Solution (Python):
input()
def unique(seq):
    return {}.fromkeys(seq).keys()
cards = len(unique([Ai for Ai in input().split()]))
print(cards if cards % 2 == 1 else cards - 1)

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

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

Solution (Python):
import sys

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


    lst = [0]* 1000000
    dup = 0
    ans =0

    for i in a:
        lst[i]+=1

    for i in lst:
        if i >0:
            ans+= 1
        if i > 1:
            dup = dup + i - 1

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

if __name__ == "__main__":
        main()

Solution (Python):
input()
cards = len(set([Ai for Ai in input().split()]))
print(cards if cards % 2 == 1 else cards - 1)

Solution (Python):
N = int(input())
A = [int(Ai) for Ai in input().split()]
cards = len(set(A))
print(cards if cards % 2 == 1 else cards - 1)

Solution (Python):
from collections import Counter

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

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

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

Solution (Python):
N = int(input())
A = map(int, input().split())
m = {}
eat = 1
for a in A:
  if a in m:
    eat += 1
  else:
    m[a] = 1
print(N - 2 * (eat // 2))

Solution (Python):

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


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


l = len([x for x in counts.values() if not x & 1])
print(len(counts) - 1 if l & 1 else len(counts))

Solution (Python):
i = int(input())
s = list(input().split())
a = len(set(s))
if a%2 == 0:
    a -= 1
print(a)