#include<stdio.h>
 
int main (void){
  int N,K;
  scanf("%d%d",&N,&K);
  int p[N];
  for(int i=0;i<K;i++){
    scanf("%d",&p[i]);
  }
  int s;
  int sum=0;
  for(int k=0;k<N;k++){
    for(int j=k;j<N;j++){
      if(p[j]<p[i]){
        s=p[i];
        p[i]=p[j];
        p[j]=s;
      }
    }
  }
  for(int l=0;l<K;l++){
    sum=sum+p[i];
  }
  printf("%d\n",sum);
  return 0;  
}