#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, tmp, nedan;
  int hako[1000];
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> hako[i];
  }
  for (int s = 0; s < n; s++) {
    for (int j = s + 1; j < n; j++) {
      if (hako[s] >= hako[j]) {
        tmp = hako[s];
        hako[s] = hako[j];
        hako[j] = tmp;
      }
    }
  }
  for (int g = 0; g < k; g++) {
    nedan = hako[g] + nedan;
  }
  cout << nedan;
  return 0;
}
