import java.util.Scanner;
import java.util.Arrays;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
      int N = scan.nextInt();
      int K = scan.nextInt();
      int[] pn = new int[N];
      int result = 0;
      
      for(int i=0; i<N; i++){
        pn[i] = scan.nextInt();
      }
      Arrays.sort(pn);
      for(int i=0; i<K; i++)
        result += pn[i];
      System.out.println(result);
    }
} import java.util.Scanner; Scanner java.util import java.util.Arrays; Arrays java.util public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
      int N = scan.nextInt();
      int K = scan.nextInt();
      int[] pn = new int[N];
      int result = 0;
      
      for(int i=0; i<N; i++){
        pn[i] = scan.nextInt();
      }
      Arrays.sort(pn);
      for(int i=0; i<K; i++)
        result += pn[i];
      System.out.println(result);
    }
} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
      int N = scan.nextInt();
      int K = scan.nextInt();
      int[] pn = new int[N];
      int result = 0;
      
      for(int i=0; i<N; i++){
        pn[i] = scan.nextInt();
      }
      Arrays.sort(pn);
      for(int i=0; i<K; i++)
        result += pn[i];
      System.out.println(result);
    } main {
		Scanner scan = new Scanner(System.in);
      int N = scan.nextInt();
      int K = scan.nextInt();
      int[] pn = new int[N];
      int result = 0;
      
      for(int i=0; i<N; i++){
        pn[i] = scan.nextInt();
      }
      Arrays.sort(pn);
      for(int i=0; i<K; i++)
        result += pn[i];
      System.out.println(result);
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int N = scan.nextInt(); N scan.nextInt() scan.nextInt scan int K = scan.nextInt(); K scan.nextInt() scan.nextInt scan int[] pn = new int[N]; pn new int[N] N int result = 0; result 0 for(int i=0; i<N; i++){
        pn[i] = scan.nextInt();
      } int i=0; int i=0; i 0 i<N i N i++ i++ i {
        pn[i] = scan.nextInt();
      } {
        pn[i] = scan.nextInt();
      } pn[i] = scan.nextInt() pn[i] pn i scan.nextInt() scan.nextInt scan Arrays.sort(pn) Arrays.sort Arrays pn for(int i=0; i<K; i++)
        result += pn[i]; int i=0; int i=0; i 0 i<K i K i++ i++ i result += pn[i]; result += pn[i] result pn[i] pn i System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
      int N = scan.nextInt();
      int K = scan.nextInt();
      int[] pn = new int[N];
      int result = 0;
      
      for(int i=0; i<N; i++){
        pn[i] = scan.nextInt();
      }
      Arrays.sort(pn);
      for(int i=0; i<K; i++)
        result += pn[i];
      System.out.println(result);
    }
} public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
      int N = scan.nextInt();
      int K = scan.nextInt();
      int[] pn = new int[N];
      int result = 0;
      
      for(int i=0; i<N; i++){
        pn[i] = scan.nextInt();
      }
      Arrays.sort(pn);
      for(int i=0; i<K; i++)
        result += pn[i];
      System.out.println(result);
    }
} Main
import java.util.Scanner;
import java.util.Arrays;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
      int N = scan.nextInt();
      int K = scan.nextInt();
      int[] pn = new int[N];
      int result = 0;
      
      for(int i=0; i<N; i++){
        pn[i] = scan.nextInt();
      }
      Arrays.sort(pn);
      for(int i=0; i<K; i++)
        result += pn[i];
      System.out.println(result);
    }
}
