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

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int len = scanner.nextInt();
        int choose = scanner.nextInt();
        int[] prices = new int[len];

        for(int index = 0; index < len; index++ ){
            prices[index] = scanner.nextInt();
        }

        Arrays.sort(prices);
        int sum = 0;
        for(int index = 0; index < choose; index++ ){
            sum += prices[index];
        }
        System.out.println(sum);
        scanner.close();
    }
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int len = scanner.nextInt();
        int choose = scanner.nextInt();
        int[] prices = new int[len];

        for(int index = 0; index < len; index++ ){
            prices[index] = scanner.nextInt();
        }

        Arrays.sort(prices);
        int sum = 0;
        for(int index = 0; index < choose; index++ ){
            sum += prices[index];
        }
        System.out.println(sum);
        scanner.close();
    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int len = scanner.nextInt();
        int choose = scanner.nextInt();
        int[] prices = new int[len];

        for(int index = 0; index < len; index++ ){
            prices[index] = scanner.nextInt();
        }

        Arrays.sort(prices);
        int sum = 0;
        for(int index = 0; index < choose; index++ ){
            sum += prices[index];
        }
        System.out.println(sum);
        scanner.close();
    } main {
        Scanner scanner = new Scanner(System.in);
        int len = scanner.nextInt();
        int choose = scanner.nextInt();
        int[] prices = new int[len];

        for(int index = 0; index < len; index++ ){
            prices[index] = scanner.nextInt();
        }

        Arrays.sort(prices);
        int sum = 0;
        for(int index = 0; index < choose; index++ ){
            sum += prices[index];
        }
        System.out.println(sum);
        scanner.close();
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int len = scanner.nextInt(); len scanner.nextInt() scanner.nextInt scanner int choose = scanner.nextInt(); choose scanner.nextInt() scanner.nextInt scanner int[] prices = new int[len]; prices new int[len] len for(int index = 0; index < len; index++ ){
            prices[index] = scanner.nextInt();
        } int index = 0; int index = 0; index 0 index < len index len index++ index++ index {
            prices[index] = scanner.nextInt();
        } {
            prices[index] = scanner.nextInt();
        } prices[index] = scanner.nextInt() prices[index] prices index scanner.nextInt() scanner.nextInt scanner Arrays.sort(prices) Arrays.sort Arrays prices int sum = 0; sum 0 for(int index = 0; index < choose; index++ ){
            sum += prices[index];
        } int index = 0; int index = 0; index 0 index < choose index choose index++ index++ index {
            sum += prices[index];
        } {
            sum += prices[index];
        } sum += prices[index] sum prices[index] prices index System.out.println(sum) System.out.println System.out System System.out sum scanner.close() scanner.close scanner String[] args args public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int len = scanner.nextInt();
        int choose = scanner.nextInt();
        int[] prices = new int[len];

        for(int index = 0; index < len; index++ ){
            prices[index] = scanner.nextInt();
        }

        Arrays.sort(prices);
        int sum = 0;
        for(int index = 0; index < choose; index++ ){
            sum += prices[index];
        }
        System.out.println(sum);
        scanner.close();
    }
} public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int len = scanner.nextInt();
        int choose = scanner.nextInt();
        int[] prices = new int[len];

        for(int index = 0; index < len; index++ ){
            prices[index] = scanner.nextInt();
        }

        Arrays.sort(prices);
        int sum = 0;
        for(int index = 0; index < choose; index++ ){
            sum += prices[index];
        }
        System.out.println(sum);
        scanner.close();
    }
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int len = scanner.nextInt();
        int choose = scanner.nextInt();
        int[] prices = new int[len];

        for(int index = 0; index < len; index++ ){
            prices[index] = scanner.nextInt();
        }

        Arrays.sort(prices);
        int sum = 0;
        for(int index = 0; index < choose; index++ ){
            sum += prices[index];
        }
        System.out.println(sum);
        scanner.close();
    }
}
