#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, i, s = 0, a[3000];
  cin >> n >> k;
  for (i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + n + 1);
  for (i = 1; i <= k; i++) s += a[i];
  cout << s;
}
