#include<bits/stdc++.h>
#define ll long long int
#define l(i,a,b) for(ll i=a;i<b;i++)
int main(){
	int n,k;
	cin>>n>>k;
	int a[n];
	l(i,0,n){
		cin>>a[i];
	}
	sort(a,a+n);
	int sum=0;
	l(i,0,k){
		sum+=a[i];
	}
  cout<<sum<<"\n";
}