#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

int a[100001];

int main() {
//	freopen("A.in", "r", stdin);
//	freopen("A.out", "w", stdout);
	
	int n, k; scanf("%d %d", &n, &k);
	long long s = 0;
	for (int i = 0; i < n; ++i) {
		int x;
		scanf("%d", &x);
		++a[x];
		s += x;
	}
	for (int i = 0; k > 0; ++i) {
		int t = min(k, a[i]);
		a[i] -= t;
		k -= t;
		s -= t * i;
	}
//	printf("%lld\n", s);
	cout<<s<<endl;
	return 0;
}
