#include<cstdio>
#include<algorithm>
using std::sort;
int n,k,a[10001],ans;
int main(){
  scanf("%d%d",&n,&k);
  for(int i=1;i<=n;i++)scanf("%d",a+i);
  sort(a+1,a+n+1);
  for(int i=1;i<=k;i++)ans+=a[i];
  printf("%d\n",ans);
}