#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  int a;
  int price[N];
  int sum = 0;
  int tmp;
  for (int i = 0; i < N; i++) {
    cin >> a;
    price[i] = a;
  }
  for (int i = 0; i < N; i++) {
    for (int j = N - 1; j >= i; j--) {
      if (price[j] < price[j - 1]) {
        tmp = price[j];
        price[j] = price[j - 1];
        price[j - 1] = tmp;
      }
    }
  }
  for (int i = 0; i < K; i++) {
    sum += price[i];
  }
  printf("%d", sum);
  return 0;
}
