#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, t, k, sum = 0;
  cin >> n >> k;
  int a[n + 1];
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n - i; j++)
      if (a[i] > a[j]) {
        t = a[i];
        a[i] = a[j];
        a[j] = t;
      }
  for (int i = 1; i <= k; i++) sum += a[i];
  cout << sum;
  return 0;
}
