unittest
{
	assert( [ "2", "5 2 8 5 1 5" ].parse.expand.solve == 10 );
	assert( [ "10", "1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000" ].parse.expand.solve == 10000000000 );
}



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 )
{
	as.sort!( ( a, b ) => b < a );
	auto ans = 0L;
	for( auto i = 1L; i < as.length / 3 * 2; i += 2 )
	{
		ans += as[ i ];
	}
	return ans;
}
