#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  int arr[1000] = {0};
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    cin >> arr[i];
  }
  int min;
  int min_j;
  for (int i = 0; i < N; i++) {
    min = arr[i];
    min_j = i;
    for (int j = i + 1; j < N; j++) {
      if (arr[i] > arr[j]) {
        min = arr[j];
        min_j = j;
      }
    }
    if (min_j = i) {
      continue;
    }
    int tmp = arr[i];
    arr[i] = min;
    arr[min_j] = tmp;
  }
  int sum = 0;
  for (int i = 0; i < K; i++) {
    sum += arr[i];
  }
  cout << sum << endl;
  return 0;
}
