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

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int k = s.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i <n ; i++) {
            arr[i] = s.nextInt();
        }
        Arrays.sort(arr);
        int count = 0;
        for (int i = 0; i < k; i++) {
            count+=arr[i];
        }
        System.out.println(count);
    }
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int k = s.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i <n ; i++) {
            arr[i] = s.nextInt();
        }
        Arrays.sort(arr);
        int count = 0;
        for (int i = 0; i < k; i++) {
            count+=arr[i];
        }
        System.out.println(count);
    }
} Main public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int k = s.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i <n ; i++) {
            arr[i] = s.nextInt();
        }
        Arrays.sort(arr);
        int count = 0;
        for (int i = 0; i < k; i++) {
            count+=arr[i];
        }
        System.out.println(count);
    } main {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int k = s.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i <n ; i++) {
            arr[i] = s.nextInt();
        }
        Arrays.sort(arr);
        int count = 0;
        for (int i = 0; i < k; i++) {
            count+=arr[i];
        }
        System.out.println(count);
    } Scanner s = new Scanner(System.in); s new Scanner(System.in) int n = s.nextInt(); n s.nextInt() s.nextInt s int k = s.nextInt(); k s.nextInt() s.nextInt s int[] arr = new int[n]; arr new int[n] n for (int i = 0; i <n ; i++) {
            arr[i] = s.nextInt();
        } int i = 0; int i = 0; i 0 i <n i n i++ i++ i {
            arr[i] = s.nextInt();
        } {
            arr[i] = s.nextInt();
        } arr[i] = s.nextInt() arr[i] arr i s.nextInt() s.nextInt s Arrays.sort(arr) Arrays.sort Arrays arr int count = 0; count 0 for (int i = 0; i < k; i++) {
            count+=arr[i];
        } int i = 0; int i = 0; i 0 i < k i k i++ i++ i {
            count+=arr[i];
        } {
            count+=arr[i];
        } count+=arr[i] count arr[i] arr i System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int k = s.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i <n ; i++) {
            arr[i] = s.nextInt();
        }
        Arrays.sort(arr);
        int count = 0;
        for (int i = 0; i < k; i++) {
            count+=arr[i];
        }
        System.out.println(count);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int k = s.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i <n ; i++) {
            arr[i] = s.nextInt();
        }
        Arrays.sort(arr);
        int count = 0;
        for (int i = 0; i < k; i++) {
            count+=arr[i];
        }
        System.out.println(count);
    }
} Main

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

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