#include<stdio.h>
void main(void)
{
	int sum = 0, top[10] = { 0 }, kazu[10], masu, kosu, i, n, t;
	scanf("%d%d", &masu, &kosu);
	for (i = 0; i < masu; i++)
	{
		scanf("%d", &kazu[i]);
	}
	for (i = 0; i < masu; i++)
	{
		for (n = i + 1;n < masu; n++)
		{
			if (kazu[i]<kazu[n])
			{
				int temp = kazu[i];
				kazu[i] = kazu[n];
				kazu[n] = temp;
			}
		}
	}
	for (i = 0; i < kosu; i++)
		sum += kazu[i];
	if (sum > 0)
		printf("%d", sum);
	else
		printf("0");
	getchar();
	getchar();
}