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