#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main()
{ int n,k;ll sum=0;
  cin>>n>>k;
  int arr[n];
  f(i,n)cin>>arr[i];
  sort(arr,arr+n);
  f(i,k)sum+=arr[i];cout<<sum;

}
