#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n;
int arr[N];
int main() {
  int k;
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", arr + i);
  }
  sort(arr + 1, arr + 1 + n);
  int ans = 0;
  for (int i = 1; i <= k; ++i) {
    ans += arr[i];
  }
  printf("%d\n", ans);
  return 0;
}
