#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; ++i) cin >> a[i];
  sort(a, a + n);
  int ans = 0;
  for (int i = 0; i < n and k > 0; ++i) ans += a[i], k--;
  cout << ans;
}
