#include<iostream>
#include<alogrithm>
using namespace std;
int main()
{
  int n,k;cin>>n>>k;
  int a[20000];
  for(int i=1;i<=n;++i) cin>>a[i];
  sort(a+1,a+1+n);
  int ans=0;
  for(int i=1;i<=k;++i) ans+=a[i];
  cout<<ans<<endl;
  return 0;
}