#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  set<int> s;
  for (int i = 0; i < n; i++) {
    s.insert(a[i]);
  }
  int sum = 0;
  int temp = 1;
  set<int>::iterator it;
  for (it = s.begin(); it != s.end(); ++it) {
    sum += *it;
    if (temp == k) {
      break;
    }
    temp++;
  }
  cout << sum << endl;
  return 0;
}
