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

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int varieties = Integer.parseInt(sc.next());
        int buyCount = Integer.parseInt(sc.next());
        int[] prices = new int[varieties];
        for (int i = 0; i < varieties; i++) {
            prices[i] = Integer.parseInt(sc.next());
        }

        Arrays.sort(prices);

        int sum = 0;
        for (int i = 0; i < buyCount; i++) {
            sum += prices[i];
        }

        System.out.println(sum);
        sc.close();
    }
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int varieties = Integer.parseInt(sc.next());
        int buyCount = Integer.parseInt(sc.next());
        int[] prices = new int[varieties];
        for (int i = 0; i < varieties; i++) {
            prices[i] = Integer.parseInt(sc.next());
        }

        Arrays.sort(prices);

        int sum = 0;
        for (int i = 0; i < buyCount; i++) {
            sum += prices[i];
        }

        System.out.println(sum);
        sc.close();
    }
} Main public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int varieties = Integer.parseInt(sc.next());
        int buyCount = Integer.parseInt(sc.next());
        int[] prices = new int[varieties];
        for (int i = 0; i < varieties; i++) {
            prices[i] = Integer.parseInt(sc.next());
        }

        Arrays.sort(prices);

        int sum = 0;
        for (int i = 0; i < buyCount; i++) {
            sum += prices[i];
        }

        System.out.println(sum);
        sc.close();
    } main {

        Scanner sc = new Scanner(System.in);

        int varieties = Integer.parseInt(sc.next());
        int buyCount = Integer.parseInt(sc.next());
        int[] prices = new int[varieties];
        for (int i = 0; i < varieties; i++) {
            prices[i] = Integer.parseInt(sc.next());
        }

        Arrays.sort(prices);

        int sum = 0;
        for (int i = 0; i < buyCount; i++) {
            sum += prices[i];
        }

        System.out.println(sum);
        sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int varieties = Integer.parseInt(sc.next()); varieties Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int buyCount = Integer.parseInt(sc.next()); buyCount Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int[] prices = new int[varieties]; prices new int[varieties] varieties for (int i = 0; i < varieties; i++) {
            prices[i] = Integer.parseInt(sc.next());
        } int i = 0; int i = 0; i 0 i < varieties i varieties i++ i++ i {
            prices[i] = Integer.parseInt(sc.next());
        } {
            prices[i] = Integer.parseInt(sc.next());
        } prices[i] = Integer.parseInt(sc.next()) prices[i] prices i Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc Arrays.sort(prices) Arrays.sort Arrays prices int sum = 0; sum 0 for (int i = 0; i < buyCount; i++) {
            sum += prices[i];
        } int i = 0; int i = 0; i 0 i < buyCount i buyCount i++ i++ i {
            sum += prices[i];
        } {
            sum += prices[i];
        } sum += prices[i] sum prices[i] prices i System.out.println(sum) System.out.println System.out System System.out sum sc.close() sc.close sc String[] args args public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int varieties = Integer.parseInt(sc.next());
        int buyCount = Integer.parseInt(sc.next());
        int[] prices = new int[varieties];
        for (int i = 0; i < varieties; i++) {
            prices[i] = Integer.parseInt(sc.next());
        }

        Arrays.sort(prices);

        int sum = 0;
        for (int i = 0; i < buyCount; i++) {
            sum += prices[i];
        }

        System.out.println(sum);
        sc.close();
    }
} public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int varieties = Integer.parseInt(sc.next());
        int buyCount = Integer.parseInt(sc.next());
        int[] prices = new int[varieties];
        for (int i = 0; i < varieties; i++) {
            prices[i] = Integer.parseInt(sc.next());
        }

        Arrays.sort(prices);

        int sum = 0;
        for (int i = 0; i < buyCount; i++) {
            sum += prices[i];
        }

        System.out.println(sum);
        sc.close();
    }
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int varieties = Integer.parseInt(sc.next());
        int buyCount = Integer.parseInt(sc.next());
        int[] prices = new int[varieties];
        for (int i = 0; i < varieties; i++) {
            prices[i] = Integer.parseInt(sc.next());
        }

        Arrays.sort(prices);

        int sum = 0;
        for (int i = 0; i < buyCount; i++) {
            sum += prices[i];
        }

        System.out.println(sum);
        sc.close();
    }
}
