unittest
{
	assert( [ "5", "1 1 2 2 2" ].parse.expand.solve == 2 );
	assert( [ "3", "1 2 1" ].parse.expand.solve == 0 );
	assert( [ "5", "1 1 1 1 1" ].parse.expand.solve == 2 );
	assert( [ "14", "1 2 2 3 3 3 4 4 4 4 1 2 3 4" ].parse.expand.solve == 4 );
}



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

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

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

auto solve( long[] as )
{
	auto bs = as.group.filter!( ( a ) => ( 2 <= a[ 1 ] ) );
	auto cs = bs.map!( ( a ) => a[ 1 ] / 2 );
	return cs.sum;
}
