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