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