import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] numList = sc.nextLine().split(" ");
        String[] priceList = sc.nextLine().split(" ");

        int sumNumber = Integer.parseInt(numList[1]);

        //sort priceList by asc
        ArrayList<Integer> priceListAsc = new ArrayList<>();
        for(String str : priceList){
            priceListAsc.add(Integer.parseInt(str));
        }

        Collections.sort(priceListAsc);
        int minSum = 0;
        for(int i = 0;i < sumNumber; i++){
            minSum = minSum + priceListAsc.get(i);
        }
        System.out.println(minSum);
    }
} import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] numList = sc.nextLine().split(" ");
        String[] priceList = sc.nextLine().split(" ");

        int sumNumber = Integer.parseInt(numList[1]);

        //sort priceList by asc
        ArrayList<Integer> priceListAsc = new ArrayList<>();
        for(String str : priceList){
            priceListAsc.add(Integer.parseInt(str));
        }

        Collections.sort(priceListAsc);
        int minSum = 0;
        for(int i = 0;i < sumNumber; i++){
            minSum = minSum + priceListAsc.get(i);
        }
        System.out.println(minSum);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] numList = sc.nextLine().split(" ");
        String[] priceList = sc.nextLine().split(" ");

        int sumNumber = Integer.parseInt(numList[1]);

        //sort priceList by asc
        ArrayList<Integer> priceListAsc = new ArrayList<>();
        for(String str : priceList){
            priceListAsc.add(Integer.parseInt(str));
        }

        Collections.sort(priceListAsc);
        int minSum = 0;
        for(int i = 0;i < sumNumber; i++){
            minSum = minSum + priceListAsc.get(i);
        }
        System.out.println(minSum);
    } main {
        Scanner sc = new Scanner(System.in);
        String[] numList = sc.nextLine().split(" ");
        String[] priceList = sc.nextLine().split(" ");

        int sumNumber = Integer.parseInt(numList[1]);

        //sort priceList by asc
        ArrayList<Integer> priceListAsc = new ArrayList<>();
        for(String str : priceList){
            priceListAsc.add(Integer.parseInt(str));
        }

        Collections.sort(priceListAsc);
        int minSum = 0;
        for(int i = 0;i < sumNumber; i++){
            minSum = minSum + priceListAsc.get(i);
        }
        System.out.println(minSum);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String[] numList = sc.nextLine().split(" "); numList sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine sc " " String[] priceList = sc.nextLine().split(" "); priceList sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine sc " " int sumNumber = Integer.parseInt(numList[1]); sumNumber Integer.parseInt(numList[1]) Integer.parseInt Integer numList[1] numList 1 ArrayList<Integer> priceListAsc = new ArrayList<>(); priceListAsc new ArrayList<>() for(String str : priceList){
            priceListAsc.add(Integer.parseInt(str));
        } String str priceList {
            priceListAsc.add(Integer.parseInt(str));
        } {
            priceListAsc.add(Integer.parseInt(str));
        } priceListAsc.add(Integer.parseInt(str)) priceListAsc.add priceListAsc Integer.parseInt(str) Integer.parseInt Integer str Collections.sort(priceListAsc) Collections.sort Collections priceListAsc int minSum = 0; minSum 0 for(int i = 0;i < sumNumber; i++){
            minSum = minSum + priceListAsc.get(i);
        } int i = 0; int i = 0; i 0 i < sumNumber i sumNumber i++ i++ i {
            minSum = minSum + priceListAsc.get(i);
        } {
            minSum = minSum + priceListAsc.get(i);
        } minSum = minSum + priceListAsc.get(i) minSum minSum + priceListAsc.get(i) minSum priceListAsc.get(i) priceListAsc.get priceListAsc i System.out.println(minSum) System.out.println System.out System System.out minSum String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] numList = sc.nextLine().split(" ");
        String[] priceList = sc.nextLine().split(" ");

        int sumNumber = Integer.parseInt(numList[1]);

        //sort priceList by asc
        ArrayList<Integer> priceListAsc = new ArrayList<>();
        for(String str : priceList){
            priceListAsc.add(Integer.parseInt(str));
        }

        Collections.sort(priceListAsc);
        int minSum = 0;
        for(int i = 0;i < sumNumber; i++){
            minSum = minSum + priceListAsc.get(i);
        }
        System.out.println(minSum);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] numList = sc.nextLine().split(" ");
        String[] priceList = sc.nextLine().split(" ");

        int sumNumber = Integer.parseInt(numList[1]);

        //sort priceList by asc
        ArrayList<Integer> priceListAsc = new ArrayList<>();
        for(String str : priceList){
            priceListAsc.add(Integer.parseInt(str));
        }

        Collections.sort(priceListAsc);
        int minSum = 0;
        for(int i = 0;i < sumNumber; i++){
            minSum = minSum + priceListAsc.get(i);
        }
        System.out.println(minSum);
    }
} Main
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] numList = sc.nextLine().split(" ");
        String[] priceList = sc.nextLine().split(" ");

        int sumNumber = Integer.parseInt(numList[1]);

        //sort priceList by asc
        ArrayList<Integer> priceListAsc = new ArrayList<>();
        for(String str : priceList){
            priceListAsc.add(Integer.parseInt(str));
        }

        Collections.sort(priceListAsc);
        int minSum = 0;
        for(int i = 0;i < sumNumber; i++){
            minSum = minSum + priceListAsc.get(i);
        }
        System.out.println(minSum);
    }
}
