#include <bits/stdc++.h>
using namespace std;
const long long mod1 = 1e9 + 7;
const long long mod2 = 998244353;
const int INF = 0x3f3f3f3f;
int n, ans, a[1005], k;
int main() {
  cin >> n, k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + 1 + n);
  for (int i = 1; i <= k; i++) ans += a[i];
  cout << ans;
  return 0;
}
