#include <bits/stdc++.h>
using namespace std;
int main() {
  int i;
  int b, c;
  int a[i];
  int sum = 0;
  cin >> b >> c;
  cout << endl;
  for (int i = 0; i < b; i++) {
    int a[i];
    cin >> a[i];
  }
  sort(a, a + b);
  for (int i = 0; i < c; i++) {
    int a[i];
    sum += a[i];
  }
  cout << sum << endl;
  return 0;
}
