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