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