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

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        int k = scanner.nextInt();

        int[] prices = new int[n];
        for (int i = 0; i < n; i++) {
            prices[i] = scanner.nextInt();
        }

        Arrays.sort(prices);

        int price = 0;
        for (int i = 0; i < k; i++) {
            price += prices[i];
        }

        System.out.println(price);
    }
} 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 n = scanner.nextInt();
        int k = scanner.nextInt();

        int[] prices = new int[n];
        for (int i = 0; i < n; i++) {
            prices[i] = scanner.nextInt();
        }

        Arrays.sort(prices);

        int price = 0;
        for (int i = 0; i < k; i++) {
            price += prices[i];
        }

        System.out.println(price);
    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        int k = scanner.nextInt();

        int[] prices = new int[n];
        for (int i = 0; i < n; i++) {
            prices[i] = scanner.nextInt();
        }

        Arrays.sort(prices);

        int price = 0;
        for (int i = 0; i < k; i++) {
            price += prices[i];
        }

        System.out.println(price);
    } main {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        int k = scanner.nextInt();

        int[] prices = new int[n];
        for (int i = 0; i < n; i++) {
            prices[i] = scanner.nextInt();
        }

        Arrays.sort(prices);

        int price = 0;
        for (int i = 0; i < k; i++) {
            price += prices[i];
        }

        System.out.println(price);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int n = scanner.nextInt(); n scanner.nextInt() scanner.nextInt scanner int k = scanner.nextInt(); k scanner.nextInt() scanner.nextInt scanner int[] prices = new int[n]; prices new int[n] n for (int i = 0; i < n; i++) {
            prices[i] = scanner.nextInt();
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            prices[i] = scanner.nextInt();
        } {
            prices[i] = scanner.nextInt();
        } prices[i] = scanner.nextInt() prices[i] prices i scanner.nextInt() scanner.nextInt scanner Arrays.sort(prices) Arrays.sort Arrays prices int price = 0; price 0 for (int i = 0; i < k; i++) {
            price += prices[i];
        } int i = 0; int i = 0; i 0 i < k i k i++ i++ i {
            price += prices[i];
        } {
            price += prices[i];
        } price += prices[i] price prices[i] 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);

        int n = scanner.nextInt();
        int k = scanner.nextInt();

        int[] prices = new int[n];
        for (int i = 0; i < n; i++) {
            prices[i] = scanner.nextInt();
        }

        Arrays.sort(prices);

        int price = 0;
        for (int i = 0; i < k; i++) {
            price += prices[i];
        }

        System.out.println(price);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        int k = scanner.nextInt();

        int[] prices = new int[n];
        for (int i = 0; i < n; i++) {
            prices[i] = scanner.nextInt();
        }

        Arrays.sort(prices);

        int price = 0;
        for (int i = 0; i < k; i++) {
            price += prices[i];
        }

        System.out.println(price);
    }
} 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 n = scanner.nextInt();
        int k = scanner.nextInt();

        int[] prices = new int[n];
        for (int i = 0; i < n; i++) {
            prices[i] = scanner.nextInt();
        }

        Arrays.sort(prices);

        int price = 0;
        for (int i = 0; i < k; i++) {
            price += prices[i];
        }

        System.out.println(price);
    }
}
