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

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str1 = scanner.nextLine();
        String str2 = scanner.nextLine();
        int price = 0;
        List<Integer> prices = new ArrayList<>();
        int N = Integer.parseInt(str1.split(" ")[0]);
        int K = Integer.parseInt(str1.split(" ")[1]);
        for(String s : str2.split(" ")){
            prices.add(Integer.parseInt(s));
        }
        Collections.sort(prices);
        for (int i = 0; i < K; i++) {
            price += prices.get(i);
        }
        System.out.println(price);
    }
} import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str1 = scanner.nextLine();
        String str2 = scanner.nextLine();
        int price = 0;
        List<Integer> prices = new ArrayList<>();
        int N = Integer.parseInt(str1.split(" ")[0]);
        int K = Integer.parseInt(str1.split(" ")[1]);
        for(String s : str2.split(" ")){
            prices.add(Integer.parseInt(s));
        }
        Collections.sort(prices);
        for (int i = 0; i < K; i++) {
            price += prices.get(i);
        }
        System.out.println(price);
    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str1 = scanner.nextLine();
        String str2 = scanner.nextLine();
        int price = 0;
        List<Integer> prices = new ArrayList<>();
        int N = Integer.parseInt(str1.split(" ")[0]);
        int K = Integer.parseInt(str1.split(" ")[1]);
        for(String s : str2.split(" ")){
            prices.add(Integer.parseInt(s));
        }
        Collections.sort(prices);
        for (int i = 0; i < K; i++) {
            price += prices.get(i);
        }
        System.out.println(price);
    } main {
        Scanner scanner = new Scanner(System.in);
        String str1 = scanner.nextLine();
        String str2 = scanner.nextLine();
        int price = 0;
        List<Integer> prices = new ArrayList<>();
        int N = Integer.parseInt(str1.split(" ")[0]);
        int K = Integer.parseInt(str1.split(" ")[1]);
        for(String s : str2.split(" ")){
            prices.add(Integer.parseInt(s));
        }
        Collections.sort(prices);
        for (int i = 0; i < K; i++) {
            price += prices.get(i);
        }
        System.out.println(price);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) String str1 = scanner.nextLine(); str1 scanner.nextLine() scanner.nextLine scanner String str2 = scanner.nextLine(); str2 scanner.nextLine() scanner.nextLine scanner int price = 0; price 0 List<Integer> prices = new ArrayList<>(); prices new ArrayList<>() int N = Integer.parseInt(str1.split(" ")[0]); N Integer.parseInt(str1.split(" ")[0]) Integer.parseInt Integer str1.split(" ")[0] str1.split(" ") str1.split str1 " " 0 int K = Integer.parseInt(str1.split(" ")[1]); K Integer.parseInt(str1.split(" ")[1]) Integer.parseInt Integer str1.split(" ")[1] str1.split(" ") str1.split str1 " " 1 for(String s : str2.split(" ")){
            prices.add(Integer.parseInt(s));
        } String s str2.split(" ") str2.split str2 " " {
            prices.add(Integer.parseInt(s));
        } {
            prices.add(Integer.parseInt(s));
        } prices.add(Integer.parseInt(s)) prices.add prices Integer.parseInt(s) Integer.parseInt Integer s Collections.sort(prices) Collections.sort Collections prices for (int i = 0; i < K; i++) {
            price += prices.get(i);
        } int i = 0; int i = 0; i 0 i < K i K i++ i++ i {
            price += prices.get(i);
        } {
            price += prices.get(i);
        } price += prices.get(i) price prices.get(i) prices.get prices i System.out.println(price) System.out.println System.out System System.out price String[] args args public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str1 = scanner.nextLine();
        String str2 = scanner.nextLine();
        int price = 0;
        List<Integer> prices = new ArrayList<>();
        int N = Integer.parseInt(str1.split(" ")[0]);
        int K = Integer.parseInt(str1.split(" ")[1]);
        for(String s : str2.split(" ")){
            prices.add(Integer.parseInt(s));
        }
        Collections.sort(prices);
        for (int i = 0; i < K; i++) {
            price += prices.get(i);
        }
        System.out.println(price);
    }
} public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str1 = scanner.nextLine();
        String str2 = scanner.nextLine();
        int price = 0;
        List<Integer> prices = new ArrayList<>();
        int N = Integer.parseInt(str1.split(" ")[0]);
        int K = Integer.parseInt(str1.split(" ")[1]);
        for(String s : str2.split(" ")){
            prices.add(Integer.parseInt(s));
        }
        Collections.sort(prices);
        for (int i = 0; i < K; i++) {
            price += prices.get(i);
        }
        System.out.println(price);
    }
} Main

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

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str1 = scanner.nextLine();
        String str2 = scanner.nextLine();
        int price = 0;
        List<Integer> prices = new ArrayList<>();
        int N = Integer.parseInt(str1.split(" ")[0]);
        int K = Integer.parseInt(str1.split(" ")[1]);
        for(String s : str2.split(" ")){
            prices.add(Integer.parseInt(s));
        }
        Collections.sort(prices);
        for (int i = 0; i < K; i++) {
            price += prices.get(i);
        }
        System.out.println(price);
    }
}