#include<bits/stdc++.h>
using namespace std;
int arr[1010]
int main()
{
  int n, k;
  cin>>n>>k;
  for(int i = 0;i<n;i++)
    cin>>arr[i]
   sort(arr,arr+n)
    int total=0;
  for(int i=0;i<k;i++)total+=arr[i]
    count<<total<<endl;
  }

  