import java.util.*;

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

public class Main {
    public static void main(String[] args ) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] all = new int[N];
        for(int i = 0;i < N;i++) {
            all[i] = sc.nextInt();
        }
        Arrays.sort(all);
        int buy = 0;
        for(int i = 0;i < K;i++){
            buy += all[i];
        }
        System.out.println(buy);
    }
}
