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