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 in Java7 (OpenJDK 1.7.0) (judge verdict: Accepted)

import java.io.*;
import java.util.*;
class Main
{
    static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	static FastScanner sc=new FastScanner(br);
    static PrintWriter out=new PrintWriter(System.out);
	static Random rnd=new Random();
	static int maxn=(int)1e5+5;
	static Node[] tree;
	
	static Node merge(Node n1,Node n2)
	{
		if(n1.val>n2.val)
		{
			return new Node(n1.idx,n1.val);
		}
		return new Node(n2.idx,n2.val);
	}
	
	static void update(int node,int s,int e,int l,int r,int val)
	{
		if(s>e || l>e || r<s)
		{
			return;
		}
		if(s==e)
		{
			tree[node].val+=val;
		}
		else
		{
			int mid=(s+e)>>1;
			update(node<<1,s,mid,l,r,val);update(node<<1|1,mid+1,e,l,r,val);
			tree[node]=merge(tree[node<<1],tree[node<<1|1]);
		}
	}
	
	static Node query(int node,int s,int e,int l,int r)
	{
		if(s>e || l>e || r<s)
		{
			return new Node(-1,0);
		}
		if(l<=s && r>=e)
		{
			return tree[node];
		}
		else
		{
			int mid=(s+e)>>1;
			Node n1=query(node<<1,s,mid,l,r),n2=query(node<<1|1,mid+1,e,l,r);
			return merge(n1,n2);
		}
	}
	
	static void build(int node,int s,int e)
	{
		if(s>e)	
		{
			return;
		}
		if(s==e)
		{
			tree[node]=new Node(s,0);
		}
		else
		{
			int mid=(s+e)>>1;
			build(node<<1,s,mid);build(node<<1|1,mid+1,e);
			tree[node]=merge(tree[node<<1],tree[node<<1|1]);
		}
	}
	
    public static void main(String args[]) throws Exception
    {
		int n=sc.nextInt();int[] a=new int[n];tree=new Node[4*maxn];build(1,0,maxn-1);
		for(int i=0;i<n;i++)
		{
			a[i]=sc.nextInt();update(1,0,maxn-1,a[i],a[i],1);
		}
		boolean check=true;int res=0;
		while(check)
		{
			Node curr=query(1,0,maxn-1,0,maxn-1);
			if(curr.val<=1)
			{
				check=false;break;
			}
			else
			{
				Node curr2=merge(query(1,0,maxn-1,0,curr.idx-1),query(1,0,maxn-1,curr.idx+1,maxn-1));
				//out.println(curr.idx+" "+curr2.idx);
				update(1,0,maxn-1,curr.idx,curr.idx,-1);
				update(1,0,maxn-1,curr2.idx,curr2.idx,-1);
			}
		}
		for(int i=1;i<maxn;i++)
		{
			res+=Math.max(0,query(1,0,maxn-1,i,i).val);
		}
		out.println(res);out.close();
    }
}
class Node
{
	int idx,val;
	public Node(int idx,int val)
	{
		this.idx=idx;this.val=val;
	}
}
class FastScanner
{
    BufferedReader in;
    StringTokenizer st;

    public FastScanner(BufferedReader in) {
        this.in = in;
    }
	
    public String nextToken() throws Exception {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }
	
	public String next() throws Exception {
		return nextToken().toString();
	}
	
    public int nextInt() throws Exception {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    public double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }
}