#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using lli = long long int;
int main() {
  int N, K, temp, result = 0;
  vector<int> price;
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    cin >> temp;
    price.push_back(temp);
  }
  sort(price.begin(), price.end());
  for (int i = 0; i < 3 && i < K; i++) {
    result += price.at(i);
  }
  cout << result << endl;
  return 0;
}
