#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, tmp, o;
  int i = 0;
  cin >> n >> k;
  int j = 0;
  int S[n];
  while (i < n) {
    cin >> S[i];
    i++;
  }
  i = 0;
  while (j < n) {
    i = 0;
    while (i + 1 < n) {
      if (S[i] > S[i + 1]) {
        tmp = S[i];
        S[i] = S[i + 1];
        S[i + 1] = tmp;
        i++;
      }
    }
    j++;
  }
  i = 0;
  while (i < k) {
    o = o + S[i];
    i++;
  }
  cout << o << endl;
  return 0;
}
