#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll LLINF = numeric_limits<long long>::max();
const int mod = 1000000007;
const int INF = 1001001001;
int main() {
  int N, K;
  cin >> N >> K;
  vector<int> P(N);
  for (int i = 0; i < N; i++) {
    cin >> P[i];
  }
  sort(P.begin(), P.end());
  int sum = 0;
  for (int i = 0; i < K; i++) {
    sum += P[i];
  }
  cout << sum;
  return 0;
}
