import java.util.*;

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

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