#include <bits/stdc++.h>
int main() {
  int k;
  int n;
  scanf("%d %d", &n, &k);
  int p[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &p[i]);
  }
  int tmp;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n - i - 1; j++) {
      if (p[j] > p[j + 1]) {
        tmp = p[j];
        p[j] = p[j + 1];
        p[j + 1] = tmp;
      }
    }
  }
  int sum;
  for (int i = 0; i < k; i++) {
    sum = sum + p[i];
  }
  printf("&d", sum);
  return 0;
}
