import std.algorithm;
import std.stdio;

void main() {
	long n, k;
	readf(" %s %s", &n, &k);
	auto h = new long[n];

	foreach (ref e;h) {
		readf(" %s", &e);
	}

	if (k >= h.length) {
		writeln("0");
		return;
	}

	sort(h);

	h[0..$ - k].reduce!"a + b".writeln;
}
