#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  int sum = 0, min = 1001;
  while (k != 0) {
    for (int i = 0; i < n; i++) {
      if (min > arr[i]) {
        min = arr[i];
      }
    }
    sum += min;
    for (int i = 0; i < n; i++) {
      if (min == arr[i]) {
        arr[i] = 1001;
        break;
      }
    }
    k--;
  }
  cout << sum;
}
