unittest
{
	assert( [ "5", "1 2 1 3 7" ].parse.expand.solve == 3 );
	assert( [ "15", "1 3 5 2 1 3 2 8 8 6 2 6 11 1 1" ].parse.expand.solve == 7 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( as );
}

auto solve( long[] as )
{
	auto d = reduce!( ( a, b ) => a + b[ 1 ] - 1 )( 0L, as.sort().group );
	d += ( d % 2 == 1 );
	return as.length.signed - d;
}
