#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, x[100010], sum = 0;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }
  sort(x, x + n);
  for (int i = 0; i < m; i++) sum += x[i];
  cout << sum << endl;
}
