#includ<stdio.h>
#include<stdlib.h>

int main(){
  int N,K,i;
  while(scanf("%d %d",&N,&K)==0);
  char s[N];
  int t=0;

  
  for(i=0;i<N;i++){
    while(scanf("%d",s[i])==0);
  }
    qsort(s,N-1,sizeof(int),compare);
  
  for(i=0;i<K,i++){
    t=t+s[i];
  }
  
  printf("%d",t)
  
  return 0;
}