#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int K, N;
  cin >> N >> K;
  int i, j;
  int a;
  double sum = 0;
  priority_queue<int, vector<int>, greater<int>> pq;
  for (i = 0; i < N; i++) {
    cin >> a;
    pq.push(a);
  }
  for (j = 0; j < K; j++) {
    a = pq.top();
    sum += a;
    pq.pop();
  }
  cout << sum << endl;
}
