#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; ++i) cin >> a[n];
  sort(a, a + n);
  int sum = 0;
  for (int i = 0; i < k; ++i) sum += a[i];
  cout << sum << "\n";
}
