#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  cin >> n >> x;
  int p[n];
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  int tmp;
  for (int i = 0; i <= n; i++) {
    for (int j = n - 1; j >= i; j--) {
      if (p[j] < p[i - 1]) {
        tmp = p[j];
        p[j] = p[j - 1];
        p[j - 1] = tmp;
      }
    }
  }
  int sum = 0;
  for (int i = 0; i < x; i++) {
    sum += p[i];
  }
  for (int i = 0; i < n; i++) {
    cout << p[i];
  }
  cout << sum;
  return 0;
}
