#include<stdio.h>

int main(void){
  int n,k;
  scanf("%d %d",&n,&k);
  int p[n];
  for(int i=0;i<n;i++){
  scanf("%d",&p[i]);
  }
  int tmp;
  for (i=0; i<n; ++i) {
    for (j=i+1; j<n; ++j) {
      if (p[i] > p[j]) {
        tmp =  p[i];
        p[i] = p[j];
        p[j] = tmp;
      }
    }
  }
  int c=0;
  
  for(int i=0;i<k;i++){
    c+=p[i];
  }
  printf("%d\n",c);
return 0;
}
    

               