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