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