import java.util.*;
public class Main {

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

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

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

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

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

} public class Main {

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

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

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

}