#include <bits/stdc++.h>
using namespace std;
int main() {
  int N = 0, K = 0;
  cin >> N >> K;
  int fruit[N];
  for (int i = 0; i < N; i++) {
    cin >> fruit[i];
  }
  sort(fruit, fruit + N);
  int ans = 0;
  for (int i = 0; i < K; i++) {
    ans += fruit[i];
  }
  return 0;
}
