#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int getint() {
  int ans(0);
  char w = getchar();
  while (w < '0' || '9' < w) w = getchar();
  while ('0' <= w && w <= '9') {
    ans = ans * 10 + w - '0';
    w = getchar();
  }
  return ans;
}
int main() {
  int n, k;
  cin >> n >> k;
  int *a = new int[n];
  for (int i = 0; i < n; i++) a[i] = getint();
  sort(a, a + n);
  int sum = 0;
  for (int i = 0; i < k; i++) sum += a[i];
  cout << sum;
  return 0;
}
