#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
int main() {
  int n, k;
  cin >> n >> k;
  int a[100];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + 100);
  int ans = 0;
  for (int j = 0; j < k; j++) {
    ans = ans + a[j];
  }
  cout << ans;
  return 0;
}
