import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner scn = new Scanner(System.in);
       
        
            int total = scn.nextInt();
            int nof = scn.nextInt();
            
            int[] prize = new int[total];
            for (int i = 0; i < total; i++) {
                prize[i]= scn.nextInt();
            }
            Arrays.sort(prize);
            int sum=0;
            for (int i = 0; i < nof; i++) {
                sum = sum + prize[i];
            }
            System.out.print(sum);



    }
} import java.io.*; io.* java import java.util.*; util.* java public class Main {

    public static void main(String[] args) throws Exception {
        Scanner scn = new Scanner(System.in);
       
        
            int total = scn.nextInt();
            int nof = scn.nextInt();
            
            int[] prize = new int[total];
            for (int i = 0; i < total; i++) {
                prize[i]= scn.nextInt();
            }
            Arrays.sort(prize);
            int sum=0;
            for (int i = 0; i < nof; i++) {
                sum = sum + prize[i];
            }
            System.out.print(sum);



    }
} Main public static void main(String[] args) throws Exception {
        Scanner scn = new Scanner(System.in);
       
        
            int total = scn.nextInt();
            int nof = scn.nextInt();
            
            int[] prize = new int[total];
            for (int i = 0; i < total; i++) {
                prize[i]= scn.nextInt();
            }
            Arrays.sort(prize);
            int sum=0;
            for (int i = 0; i < nof; i++) {
                sum = sum + prize[i];
            }
            System.out.print(sum);



    } main {
        Scanner scn = new Scanner(System.in);
       
        
            int total = scn.nextInt();
            int nof = scn.nextInt();
            
            int[] prize = new int[total];
            for (int i = 0; i < total; i++) {
                prize[i]= scn.nextInt();
            }
            Arrays.sort(prize);
            int sum=0;
            for (int i = 0; i < nof; i++) {
                sum = sum + prize[i];
            }
            System.out.print(sum);



    } Scanner scn = new Scanner(System.in); scn new Scanner(System.in) int total = scn.nextInt(); total scn.nextInt() scn.nextInt scn int nof = scn.nextInt(); nof scn.nextInt() scn.nextInt scn int[] prize = new int[total]; prize new int[total] total for (int i = 0; i < total; i++) {
                prize[i]= scn.nextInt();
            } int i = 0; int i = 0; i 0 i < total i total i++ i++ i {
                prize[i]= scn.nextInt();
            } {
                prize[i]= scn.nextInt();
            } prize[i]= scn.nextInt() prize[i] prize i scn.nextInt() scn.nextInt scn Arrays.sort(prize) Arrays.sort Arrays prize int sum=0; sum 0 for (int i = 0; i < nof; i++) {
                sum = sum + prize[i];
            } int i = 0; int i = 0; i 0 i < nof i nof i++ i++ i {
                sum = sum + prize[i];
            } {
                sum = sum + prize[i];
            } sum = sum + prize[i] sum sum + prize[i] sum prize[i] prize i System.out.print(sum) System.out.print System.out System System.out sum String[] args args public class Main {

    public static void main(String[] args) throws Exception {
        Scanner scn = new Scanner(System.in);
       
        
            int total = scn.nextInt();
            int nof = scn.nextInt();
            
            int[] prize = new int[total];
            for (int i = 0; i < total; i++) {
                prize[i]= scn.nextInt();
            }
            Arrays.sort(prize);
            int sum=0;
            for (int i = 0; i < nof; i++) {
                sum = sum + prize[i];
            }
            System.out.print(sum);



    }
} public class Main {

    public static void main(String[] args) throws Exception {
        Scanner scn = new Scanner(System.in);
       
        
            int total = scn.nextInt();
            int nof = scn.nextInt();
            
            int[] prize = new int[total];
            for (int i = 0; i < total; i++) {
                prize[i]= scn.nextInt();
            }
            Arrays.sort(prize);
            int sum=0;
            for (int i = 0; i < nof; i++) {
                sum = sum + prize[i];
            }
            System.out.print(sum);



    }
} Main
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner scn = new Scanner(System.in);
       
        
            int total = scn.nextInt();
            int nof = scn.nextInt();
            
            int[] prize = new int[total];
            for (int i = 0; i < total; i++) {
                prize[i]= scn.nextInt();
            }
            Arrays.sort(prize);
            int sum=0;
            for (int i = 0; i < nof; i++) {
                sum = sum + prize[i];
            }
            System.out.print(sum);



    }
}