#include <bits/stdc++.h>
using namespace std;
long long m, n, g, h, j, k = 1, l, i, mx = -1e9, mn = 1e9, a[1000001], b[10001],
                         s1, s2, s3;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  cin >> n >> k;
  for (i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  for (i = 0; i < k; i++) {
    s1 += a[i];
  }
  cout << s1 << endl;
}
