import java.util.*;

class Main
{
  public static void main(String [] args)
  {
    Scanner s = new Scanner(System.in);
    int n = s.nextInt();
    int k = s.nextInt();
    int [] arr = new int [n];
    
    for(int i = 0; i < n;i++)
      	arr[i] = s.nextInt();
    
    Arrays.sort(arr);
    
    int ans = 0;
    
    for(int i = 0; i < k; i++)
      ans += arr[i];
    
    System.out.println(ans);
  }
} import java.util.*; util.* java class Main
{
  public static void main(String [] args)
  {
    Scanner s = new Scanner(System.in);
    int n = s.nextInt();
    int k = s.nextInt();
    int [] arr = new int [n];
    
    for(int i = 0; i < n;i++)
      	arr[i] = s.nextInt();
    
    Arrays.sort(arr);
    
    int ans = 0;
    
    for(int i = 0; i < k; i++)
      ans += arr[i];
    
    System.out.println(ans);
  }
} Main public static void main(String [] args)
  {
    Scanner s = new Scanner(System.in);
    int n = s.nextInt();
    int k = s.nextInt();
    int [] arr = new int [n];
    
    for(int i = 0; i < n;i++)
      	arr[i] = s.nextInt();
    
    Arrays.sort(arr);
    
    int ans = 0;
    
    for(int i = 0; i < k; i++)
      ans += arr[i];
    
    System.out.println(ans);
  } main {
    Scanner s = new Scanner(System.in);
    int n = s.nextInt();
    int k = s.nextInt();
    int [] arr = new int [n];
    
    for(int i = 0; i < n;i++)
      	arr[i] = s.nextInt();
    
    Arrays.sort(arr);
    
    int ans = 0;
    
    for(int i = 0; i < k; i++)
      ans += arr[i];
    
    System.out.println(ans);
  } Scanner s = new Scanner(System.in); s new Scanner(System.in) int n = s.nextInt(); n s.nextInt() s.nextInt s int k = s.nextInt(); k s.nextInt() s.nextInt s int [] arr = new int [n]; arr new int [n] n for(int i = 0; i < n;i++)
      	arr[i] = s.nextInt(); int i = 0; int i = 0; i 0 i < n i n i++ i++ i arr[i] = s.nextInt(); arr[i] = s.nextInt() arr[i] arr i s.nextInt() s.nextInt s Arrays.sort(arr) Arrays.sort Arrays arr int ans = 0; ans 0 for(int i = 0; i < k; i++)
      ans += arr[i]; int i = 0; int i = 0; i 0 i < k i k i++ i++ i ans += arr[i]; ans += arr[i] ans arr[i] arr i System.out.println(ans) System.out.println System.out System System.out ans String [] args args
import java.util.*;

class Main
{
  public static void main(String [] args)
  {
    Scanner s = new Scanner(System.in);
    int n = s.nextInt();
    int k = s.nextInt();
    int [] arr = new int [n];
    
    for(int i = 0; i < n;i++)
      	arr[i] = s.nextInt();
    
    Arrays.sort(arr);
    
    int ans = 0;
    
    for(int i = 0; i < k; i++)
      ans += arr[i];
    
    System.out.println(ans);
  }
}