#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int a[n];
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  int sum = 0;
  sort(a + 1, a + 1 + n);
  for (int i = 1; i <= k; i++) {
    sum += a[i];
  }
  cout << sum;
  return 0;
}
