#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>

using namespace std;

int main() {
  int n,k,L[100];
  cin >> n >> k;
  for(int i = 0; i < n; i++) 
    cin >> L[i];
  
  sort(L,L+n);
  int sum = 0;
  for(int i = n-1; i >= n-k; i--)
    sum += L[i];

  cout << sum << endl;
}
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    int count = 0;

    for (size_t i = 0; i < N; i++)
    {
        cin >> A[i];
    }

    while (1)
    {
        bool exist_add = false;
        for (auto &&i : A)
        {
            if (i % 2 == 1)
            {
                exist_add = true;
            }
        }

        if (exist_add)
            break;

        for (auto &&i : A)
        {
            i /= 2;
        }

        count += 1;
    }

    cout << count << endl;
}
