#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, ans = 0;
  cin >> n >> k;
  int a[n + 5];
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  if (n == 1) {
    cout << a[1] << endl;
    return 0;
  }
  int minv = 0x7fffff, mini;
  for (int j = 1; j <= k; j++) {
    for (int i = 1; i <= n; i++) {
      if (a[i] < minv) {
        minv = a[i];
        mini = i;
      }
    }
    ans += minv;
    a[mini] = 0x7ffffff;
  }
  cout << ans << endl;
  return 0;
}
