unittest
{
	assert( [ "3 1", "4 1 5" ].parse.expand.solve == 5 );
	assert( [ "8 9", "7 9 3 2 3 8 4 6" ].parse.expand.solve == 0 );
	assert( [ "3 0", "1000000000 1000000000 1000000000" ].parse.expand.solve == 3000000000 );
}



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 ) )
{
	auto nk = input.front.split.to!( long[] );
	input.popFront;
	auto hs = input.front.split.to!( long[] );
	return tuple( nk[ 1 ], hs );
}

auto solve( long k, long[] hs )
{
	hs.sort();
	if( hs.length <= k ) return 0;
	else                 return hs[ 0 .. $ - k ].sum;
}
