#include<iostream>
#include<algorithm>
using namepspace std;
int main()
{
  int n,k;
  cin >> n >> k;
  int arr[n];
  for(int i=0; i<n; i++)
  {cin >> arr[i];}
  sort(arr,arr+n);
  int res=0;
  for(int i=0; i<k; i++)
  {res+=arr[i];}
  cout << res << endl;
  return 0;}
