#include <bits/stdc++.h>
int arr[1030];
int N, K;
int answer;
int main() {
  scanf("%d %d", &N, &K);
  for (int i = 0; i < N; i++) {
    scanf("%d", arr[i]);
  }
  std::sort(arr, arr + N);
  for (int i = 0; i < K; i++) {
    answer += arr[i];
  }
  printf("%d", answer);
}
