#include <bits/stdc++.h>
int main() {
  int kosuu;
  int shurui;
  int pri[1001];
  int i = 0;
  int n, m = 0;
  int a, b = 0;
  int goukei = 0;
  scanf("%d", &kosuu);
  scanf("%d", &shurui);
  while (i < kosuu) {
    scanf("%d", &pri[i]);
    i++;
  }
  while (kosuu > m) {
    while (kosuu > n) {
      a = pri[n];
      b = pri[n + 1];
      if (pri[n] > pri[n + 1]) {
        pri[n] = b;
        pri[n + 1] = a;
      }
      n++;
    }
    n = 0;
    m++;
  }
  i = 0;
  while (i < shurui) {
    goukei += pri[i];
    i++;
  }
  printf("%d", goukei);
  return 0;
}
