#include <bits/stdc++.h>
using namespace std;
void so(int n, int p[n]) {
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (p[i] > p[j]) {
        int t = p[i];
        p[i] = p[j];
        p[j] = t;
      }
    }
  }
}
int main() {
  int N, K;
  cin >> N >> K;
  int p[N];
  for (int i = 0; i < N; i++) cin >> p[i];
  so(N, p);
  int c = 0;
  int sum = 0;
  while (K > 0) {
    sum += p[c];
    K--;
    c++;
  }
  cout << sum << endl;
}
