#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> lol;
  for (int i = 0; i < n; i++) {
    cin >> lol[i];
  }
  sort(lol.begin(), lol.end());
  int sum = 0;
  for (int i = 0; i < k; i++) {
    sum += lol[i];
  }
  cout << sum;
}
