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