#include<stdio.h>
void swap(int *xp, int *yp)  
{  
    int temp = *xp;  
    *xp = *yp;  
    *yp = temp;  
}  
  
// A function to implement bubble sort  
void bubbleSort(int arr[], int n)  
{  
    int i, j;  
    for (i = 0; i < n-1; i++)      
    {
    // Last i elements are already in place  
    for (j = 0; j < n-i-1; j++)  
    {
        if (arr[j] > arr[j+1])  
            swap(&arr[j], &arr[j+1]);  
    }
    } 
}
int main()
{
  int n,k;
  long int sum=0;
  scanf("%d%d",&n,&k);
  for(int i=0;i<n;i++)
    scanf("%d",&a[i]);
  bubblesort(a,n);
  for(int i=0;i<k;i++)
    sum+=a[i];
  printf("%ld",sum);
  return 0;
}