#include <iostream>
#include <string>
#include <cstdio>
#include <ctime>

using namespace std;

int n,a[1000001],k;

int main()
{
	freopen("A.in","r",stdin);
	freopen("A.out","w",stdout);
	int start = clock();
	long long s = 0,ss = 0;	
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; ++i)
		scanf("%d", &a[i]), ss += a[i];
	
	sort(a,a+n);
	for (int i = 0; i < k; ++i)
		s += a[i];
	cout << ss - s << endl;	
	return 0;
}
