import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int all = scanner.nextInt();
        int num = scanner.nextInt();

        ArrayList<Integer> priceList = new ArrayList<>();
        for(int i = 0; i < all; i++) {
            priceList.add(scanner.nextInt());
        }
        Collections.sort(priceList);
        int cost = 0;
        for (int i = 0; i < num; i++) {
            cost += priceList.get(i);
        }
        System.out.println(cost);
    }
} import java.util.*; util.* java public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int all = scanner.nextInt();
        int num = scanner.nextInt();

        ArrayList<Integer> priceList = new ArrayList<>();
        for(int i = 0; i < all; i++) {
            priceList.add(scanner.nextInt());
        }
        Collections.sort(priceList);
        int cost = 0;
        for (int i = 0; i < num; i++) {
            cost += priceList.get(i);
        }
        System.out.println(cost);
    }
} Main public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int all = scanner.nextInt();
        int num = scanner.nextInt();

        ArrayList<Integer> priceList = new ArrayList<>();
        for(int i = 0; i < all; i++) {
            priceList.add(scanner.nextInt());
        }
        Collections.sort(priceList);
        int cost = 0;
        for (int i = 0; i < num; i++) {
            cost += priceList.get(i);
        }
        System.out.println(cost);
    } main {

        Scanner scanner = new Scanner(System.in);
        int all = scanner.nextInt();
        int num = scanner.nextInt();

        ArrayList<Integer> priceList = new ArrayList<>();
        for(int i = 0; i < all; i++) {
            priceList.add(scanner.nextInt());
        }
        Collections.sort(priceList);
        int cost = 0;
        for (int i = 0; i < num; i++) {
            cost += priceList.get(i);
        }
        System.out.println(cost);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int all = scanner.nextInt(); all scanner.nextInt() scanner.nextInt scanner int num = scanner.nextInt(); num scanner.nextInt() scanner.nextInt scanner ArrayList<Integer> priceList = new ArrayList<>(); priceList new ArrayList<>() for(int i = 0; i < all; i++) {
            priceList.add(scanner.nextInt());
        } int i = 0; int i = 0; i 0 i < all i all i++ i++ i {
            priceList.add(scanner.nextInt());
        } {
            priceList.add(scanner.nextInt());
        } priceList.add(scanner.nextInt()) priceList.add priceList scanner.nextInt() scanner.nextInt scanner Collections.sort(priceList) Collections.sort Collections priceList int cost = 0; cost 0 for (int i = 0; i < num; i++) {
            cost += priceList.get(i);
        } int i = 0; int i = 0; i 0 i < num i num i++ i++ i {
            cost += priceList.get(i);
        } {
            cost += priceList.get(i);
        } cost += priceList.get(i) cost priceList.get(i) priceList.get priceList i System.out.println(cost) System.out.println System.out System System.out cost String[] args args public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int all = scanner.nextInt();
        int num = scanner.nextInt();

        ArrayList<Integer> priceList = new ArrayList<>();
        for(int i = 0; i < all; i++) {
            priceList.add(scanner.nextInt());
        }
        Collections.sort(priceList);
        int cost = 0;
        for (int i = 0; i < num; i++) {
            cost += priceList.get(i);
        }
        System.out.println(cost);
    }
} public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int all = scanner.nextInt();
        int num = scanner.nextInt();

        ArrayList<Integer> priceList = new ArrayList<>();
        for(int i = 0; i < all; i++) {
            priceList.add(scanner.nextInt());
        }
        Collections.sort(priceList);
        int cost = 0;
        for (int i = 0; i < num; i++) {
            cost += priceList.get(i);
        }
        System.out.println(cost);
    }
} Main
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int all = scanner.nextInt();
        int num = scanner.nextInt();

        ArrayList<Integer> priceList = new ArrayList<>();
        for(int i = 0; i < all; i++) {
            priceList.add(scanner.nextInt());
        }
        Collections.sort(priceList);
        int cost = 0;
        for (int i = 0; i < num; i++) {
            cost += priceList.get(i);
        }
        System.out.println(cost);
    }
}