#include <bits/stdc++.h>
using namespace std;
int main() {
  int K, N, i, m = 0, sum = 0, x = 0, z;
  int p[1000];
  cin >> N >> K;
  for (i = 0; i < N; i++) cin >> p[i];
  for (z = 0; z < N && m < K; z++) {
    int min = p[0];
    for (i = 0; i < N; i++) {
      if (min > p[i]) {
        min = p[i];
        x = i;
      }
    }
    sum += min;
    m++;
    p[x] = 10000000;
  }
  cout << sum;
  return 0;
}
