import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner console = new Scanner(System.in);
        int fruitTypeNum = console.nextInt();
        int buyFruitNum = console.nextInt();
        console.nextLine();

        ArrayList<Integer> minPrices = new ArrayList<Integer>(fruitTypeNum);
        for(int i = 0; i < fruitTypeNum; i++){
            minPrices.add(console.nextInt());
        }
        Collections.sort(minPrices);

        int total = 0;
        for(int i = 0; i < buyFruitNum; i++){
            total += minPrices.get(i);
        }
        System.out.println(total);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner console = new Scanner(System.in);
        int fruitTypeNum = console.nextInt();
        int buyFruitNum = console.nextInt();
        console.nextLine();

        ArrayList<Integer> minPrices = new ArrayList<Integer>(fruitTypeNum);
        for(int i = 0; i < fruitTypeNum; i++){
            minPrices.add(console.nextInt());
        }
        Collections.sort(minPrices);

        int total = 0;
        for(int i = 0; i < buyFruitNum; i++){
            total += minPrices.get(i);
        }
        System.out.println(total);
    }
} Main public static void main(String[] args) {
        Scanner console = new Scanner(System.in);
        int fruitTypeNum = console.nextInt();
        int buyFruitNum = console.nextInt();
        console.nextLine();

        ArrayList<Integer> minPrices = new ArrayList<Integer>(fruitTypeNum);
        for(int i = 0; i < fruitTypeNum; i++){
            minPrices.add(console.nextInt());
        }
        Collections.sort(minPrices);

        int total = 0;
        for(int i = 0; i < buyFruitNum; i++){
            total += minPrices.get(i);
        }
        System.out.println(total);
    } main {
        Scanner console = new Scanner(System.in);
        int fruitTypeNum = console.nextInt();
        int buyFruitNum = console.nextInt();
        console.nextLine();

        ArrayList<Integer> minPrices = new ArrayList<Integer>(fruitTypeNum);
        for(int i = 0; i < fruitTypeNum; i++){
            minPrices.add(console.nextInt());
        }
        Collections.sort(minPrices);

        int total = 0;
        for(int i = 0; i < buyFruitNum; i++){
            total += minPrices.get(i);
        }
        System.out.println(total);
    } Scanner console = new Scanner(System.in); console new Scanner(System.in) int fruitTypeNum = console.nextInt(); fruitTypeNum console.nextInt() console.nextInt console int buyFruitNum = console.nextInt(); buyFruitNum console.nextInt() console.nextInt console console.nextLine() console.nextLine console ArrayList<Integer> minPrices = new ArrayList<Integer>(fruitTypeNum); minPrices new ArrayList<Integer>(fruitTypeNum) for(int i = 0; i < fruitTypeNum; i++){
            minPrices.add(console.nextInt());
        } int i = 0; int i = 0; i 0 i < fruitTypeNum i fruitTypeNum i++ i++ i {
            minPrices.add(console.nextInt());
        } {
            minPrices.add(console.nextInt());
        } minPrices.add(console.nextInt()) minPrices.add minPrices console.nextInt() console.nextInt console Collections.sort(minPrices) Collections.sort Collections minPrices int total = 0; total 0 for(int i = 0; i < buyFruitNum; i++){
            total += minPrices.get(i);
        } int i = 0; int i = 0; i 0 i < buyFruitNum i buyFruitNum i++ i++ i {
            total += minPrices.get(i);
        } {
            total += minPrices.get(i);
        } total += minPrices.get(i) total minPrices.get(i) minPrices.get minPrices i System.out.println(total) System.out.println System.out System System.out total String[] args args public class Main {
    public static void main(String[] args) {
        Scanner console = new Scanner(System.in);
        int fruitTypeNum = console.nextInt();
        int buyFruitNum = console.nextInt();
        console.nextLine();

        ArrayList<Integer> minPrices = new ArrayList<Integer>(fruitTypeNum);
        for(int i = 0; i < fruitTypeNum; i++){
            minPrices.add(console.nextInt());
        }
        Collections.sort(minPrices);

        int total = 0;
        for(int i = 0; i < buyFruitNum; i++){
            total += minPrices.get(i);
        }
        System.out.println(total);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner console = new Scanner(System.in);
        int fruitTypeNum = console.nextInt();
        int buyFruitNum = console.nextInt();
        console.nextLine();

        ArrayList<Integer> minPrices = new ArrayList<Integer>(fruitTypeNum);
        for(int i = 0; i < fruitTypeNum; i++){
            minPrices.add(console.nextInt());
        }
        Collections.sort(minPrices);

        int total = 0;
        for(int i = 0; i < buyFruitNum; i++){
            total += minPrices.get(i);
        }
        System.out.println(total);
    }
} Main
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner console = new Scanner(System.in);
        int fruitTypeNum = console.nextInt();
        int buyFruitNum = console.nextInt();
        console.nextLine();

        ArrayList<Integer> minPrices = new ArrayList<Integer>(fruitTypeNum);
        for(int i = 0; i < fruitTypeNum; i++){
            minPrices.add(console.nextInt());
        }
        Collections.sort(minPrices);

        int total = 0;
        for(int i = 0; i < buyFruitNum; i++){
            total += minPrices.get(i);
        }
        System.out.println(total);
    }
}
