#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, K, S;
  cin >> N >> K;
  int arr[N + 1];
  for (long long i = 0; i < N; i++) {
    cin >> arr[i];
  }
  S = sizeof(arr) / sizeof(arr[0]);
  sort(arr, arr + S);
  int Sum = 0;
  for (long long i = 0; i < K; i++) {
    Sum += arr[i];
  }
  cout << Sum << endl;
}
