import java.lang.*;
import java.util.*;

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

        int fruit = scan.nextInt();
        int num = scan.nextInt();

        int[] arr = new int[fruit];

        for (int i = 0; i < fruit; i++) {
            arr[i] = scan.nextInt();
        }

        Arrays.sort(arr);
        int sum = 0;
        for (int i = 0; i < num; i++) {
            sum += arr[i];
        }

        System.out.println(sum);
    }
} import java.lang.*; lang.* java import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int fruit = scan.nextInt();
        int num = scan.nextInt();

        int[] arr = new int[fruit];

        for (int i = 0; i < fruit; i++) {
            arr[i] = scan.nextInt();
        }

        Arrays.sort(arr);
        int sum = 0;
        for (int i = 0; i < num; i++) {
            sum += arr[i];
        }

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

        int fruit = scan.nextInt();
        int num = scan.nextInt();

        int[] arr = new int[fruit];

        for (int i = 0; i < fruit; i++) {
            arr[i] = scan.nextInt();
        }

        Arrays.sort(arr);
        int sum = 0;
        for (int i = 0; i < num; i++) {
            sum += arr[i];
        }

        System.out.println(sum);
    } main {
        Scanner scan = new Scanner(System.in);

        int fruit = scan.nextInt();
        int num = scan.nextInt();

        int[] arr = new int[fruit];

        for (int i = 0; i < fruit; i++) {
            arr[i] = scan.nextInt();
        }

        Arrays.sort(arr);
        int sum = 0;
        for (int i = 0; i < num; i++) {
            sum += arr[i];
        }

        System.out.println(sum);
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int fruit = scan.nextInt(); fruit scan.nextInt() scan.nextInt scan int num = scan.nextInt(); num scan.nextInt() scan.nextInt scan int[] arr = new int[fruit]; arr new int[fruit] fruit for (int i = 0; i < fruit; i++) {
            arr[i] = scan.nextInt();
        } int i = 0; int i = 0; i 0 i < fruit i fruit i++ i++ i {
            arr[i] = scan.nextInt();
        } {
            arr[i] = scan.nextInt();
        } arr[i] = scan.nextInt() arr[i] arr i scan.nextInt() scan.nextInt scan Arrays.sort(arr) Arrays.sort Arrays arr int sum = 0; sum 0 for (int i = 0; i < num; i++) {
            sum += arr[i];
        } int i = 0; int i = 0; i 0 i < num i num i++ i++ i {
            sum += arr[i];
        } {
            sum += arr[i];
        } sum += arr[i] sum arr[i] arr i System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int fruit = scan.nextInt();
        int num = scan.nextInt();

        int[] arr = new int[fruit];

        for (int i = 0; i < fruit; i++) {
            arr[i] = scan.nextInt();
        }

        Arrays.sort(arr);
        int sum = 0;
        for (int i = 0; i < num; i++) {
            sum += arr[i];
        }

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

        int fruit = scan.nextInt();
        int num = scan.nextInt();

        int[] arr = new int[fruit];

        for (int i = 0; i < fruit; i++) {
            arr[i] = scan.nextInt();
        }

        Arrays.sort(arr);
        int sum = 0;
        for (int i = 0; i < num; i++) {
            sum += arr[i];
        }

        System.out.println(sum);
    }
} Main
import java.lang.*;
import java.util.*;

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

        int fruit = scan.nextInt();
        int num = scan.nextInt();

        int[] arr = new int[fruit];

        for (int i = 0; i < fruit; i++) {
            arr[i] = scan.nextInt();
        }

        Arrays.sort(arr);
        int sum = 0;
        for (int i = 0; i < num; i++) {
            sum += arr[i];
        }

        System.out.println(sum);
    }
}
