import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int total = sc.nextInt();
        int pickCount = sc.nextInt();
        int[] numbers = new int[total];
        int result = 0;
        for(int i = 0 ; i < total ; i++){
            numbers[i] = sc.nextInt();
        }
        Arrays.sort(numbers);
        for(int i = 0; i < pickCount ; i++){
            result += numbers[i];
        }
        System.out.println(result);
    }
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int total = sc.nextInt();
        int pickCount = sc.nextInt();
        int[] numbers = new int[total];
        int result = 0;
        for(int i = 0 ; i < total ; i++){
            numbers[i] = sc.nextInt();
        }
        Arrays.sort(numbers);
        for(int i = 0; i < pickCount ; i++){
            result += numbers[i];
        }
        System.out.println(result);
    }
} Main public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int total = sc.nextInt();
        int pickCount = sc.nextInt();
        int[] numbers = new int[total];
        int result = 0;
        for(int i = 0 ; i < total ; i++){
            numbers[i] = sc.nextInt();
        }
        Arrays.sort(numbers);
        for(int i = 0; i < pickCount ; i++){
            result += numbers[i];
        }
        System.out.println(result);
    } main {

        Scanner sc = new Scanner(System.in);
        int total = sc.nextInt();
        int pickCount = sc.nextInt();
        int[] numbers = new int[total];
        int result = 0;
        for(int i = 0 ; i < total ; i++){
            numbers[i] = sc.nextInt();
        }
        Arrays.sort(numbers);
        for(int i = 0; i < pickCount ; i++){
            result += numbers[i];
        }
        System.out.println(result);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int total = sc.nextInt(); total sc.nextInt() sc.nextInt sc int pickCount = sc.nextInt(); pickCount sc.nextInt() sc.nextInt sc int[] numbers = new int[total]; numbers new int[total] total int result = 0; result 0 for(int i = 0 ; i < total ; i++){
            numbers[i] = sc.nextInt();
        } int i = 0 ; int i = 0 ; i 0 i < total i total i++ i++ i {
            numbers[i] = sc.nextInt();
        } {
            numbers[i] = sc.nextInt();
        } numbers[i] = sc.nextInt() numbers[i] numbers i sc.nextInt() sc.nextInt sc Arrays.sort(numbers) Arrays.sort Arrays numbers for(int i = 0; i < pickCount ; i++){
            result += numbers[i];
        } int i = 0; int i = 0; i 0 i < pickCount i pickCount i++ i++ i {
            result += numbers[i];
        } {
            result += numbers[i];
        } result += numbers[i] result numbers[i] numbers 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 sc = new Scanner(System.in);
        int total = sc.nextInt();
        int pickCount = sc.nextInt();
        int[] numbers = new int[total];
        int result = 0;
        for(int i = 0 ; i < total ; i++){
            numbers[i] = sc.nextInt();
        }
        Arrays.sort(numbers);
        for(int i = 0; i < pickCount ; i++){
            result += numbers[i];
        }
        System.out.println(result);
    }
} public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int total = sc.nextInt();
        int pickCount = sc.nextInt();
        int[] numbers = new int[total];
        int result = 0;
        for(int i = 0 ; i < total ; i++){
            numbers[i] = sc.nextInt();
        }
        Arrays.sort(numbers);
        for(int i = 0; i < pickCount ; i++){
            result += numbers[i];
        }
        System.out.println(result);
    }
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int total = sc.nextInt();
        int pickCount = sc.nextInt();
        int[] numbers = new int[total];
        int result = 0;
        for(int i = 0 ; i < total ; i++){
            numbers[i] = sc.nextInt();
        }
        Arrays.sort(numbers);
        for(int i = 0; i < pickCount ; i++){
            result += numbers[i];
        }
        System.out.println(result);
    }
}
