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

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

        int n = Integer.parseInt(nums[0]);
        int k = Integer.parseInt(nums[1]);

        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = Integer.parseInt(ps[i]);
        }
        Arrays.sort(arr);
        int sum = 0;
        for (int j = 0; j < k; j++) {
            sum += arr[j];
        }
        System.out.println(sum);
    }
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] nums = sc.nextLine().split(" ");
        String[] ps = sc.nextLine().split(" ");

        int n = Integer.parseInt(nums[0]);
        int k = Integer.parseInt(nums[1]);

        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = Integer.parseInt(ps[i]);
        }
        Arrays.sort(arr);
        int sum = 0;
        for (int j = 0; j < k; j++) {
            sum += arr[j];
        }
        System.out.println(sum);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] nums = sc.nextLine().split(" ");
        String[] ps = sc.nextLine().split(" ");

        int n = Integer.parseInt(nums[0]);
        int k = Integer.parseInt(nums[1]);

        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = Integer.parseInt(ps[i]);
        }
        Arrays.sort(arr);
        int sum = 0;
        for (int j = 0; j < k; j++) {
            sum += arr[j];
        }
        System.out.println(sum);
    } main {
        Scanner sc = new Scanner(System.in);
        String[] nums = sc.nextLine().split(" ");
        String[] ps = sc.nextLine().split(" ");

        int n = Integer.parseInt(nums[0]);
        int k = Integer.parseInt(nums[1]);

        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = Integer.parseInt(ps[i]);
        }
        Arrays.sort(arr);
        int sum = 0;
        for (int j = 0; j < k; j++) {
            sum += arr[j];
        }
        System.out.println(sum);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String[] nums = sc.nextLine().split(" "); nums sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine sc " " String[] ps = sc.nextLine().split(" "); ps sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine sc " " int n = Integer.parseInt(nums[0]); n Integer.parseInt(nums[0]) Integer.parseInt Integer nums[0] nums 0 int k = Integer.parseInt(nums[1]); k Integer.parseInt(nums[1]) Integer.parseInt Integer nums[1] nums 1 int[] arr = new int[n]; arr new int[n] n for (int i = 0; i < n; i++) {
            arr[i] = Integer.parseInt(ps[i]);
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            arr[i] = Integer.parseInt(ps[i]);
        } {
            arr[i] = Integer.parseInt(ps[i]);
        } arr[i] = Integer.parseInt(ps[i]) arr[i] arr i Integer.parseInt(ps[i]) Integer.parseInt Integer ps[i] ps i Arrays.sort(arr) Arrays.sort Arrays arr int sum = 0; sum 0 for (int j = 0; j < k; j++) {
            sum += arr[j];
        } int j = 0; int j = 0; j 0 j < k j k j++ j++ j {
            sum += arr[j];
        } {
            sum += arr[j];
        } sum += arr[j] sum arr[j] arr j System.out.println(sum) System.out.println System.out System System.out sum String[] args args
import java.util.Arrays;
import java.util.Scanner;

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

        int n = Integer.parseInt(nums[0]);
        int k = Integer.parseInt(nums[1]);

        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = Integer.parseInt(ps[i]);
        }
        Arrays.sort(arr);
        int sum = 0;
        for (int j = 0; j < k; j++) {
            sum += arr[j];
        }
        System.out.println(sum);
    }
}
