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