import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);

        int[] a = new int[2];
        a[0] = sc.nextInt();
        a[1] = sc.nextInt();
        int idx = a[0] - 1;
        Integer[] numbers = new Integer[a[0]];
        int i = 0;
        while (sc.hasNext()) {
          numbers[i] = sc.nextInt();
          i++;
        }
        for (int p=i; p<a[0]; p++) {
          numbers[p] = 9999;
        }
		Arrays.sort(numbers);
        int total = 0;
        for (int q=0; q<a[1]; q++) {
          total = total + numbers[q];
        }
        System.out.println(total);        
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);

        int[] a = new int[2];
        a[0] = sc.nextInt();
        a[1] = sc.nextInt();
        int idx = a[0] - 1;
        Integer[] numbers = new Integer[a[0]];
        int i = 0;
        while (sc.hasNext()) {
          numbers[i] = sc.nextInt();
          i++;
        }
        for (int p=i; p<a[0]; p++) {
          numbers[p] = 9999;
        }
		Arrays.sort(numbers);
        int total = 0;
        for (int q=0; q<a[1]; q++) {
          total = total + numbers[q];
        }
        System.out.println(total);        
    }
} Main public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);

        int[] a = new int[2];
        a[0] = sc.nextInt();
        a[1] = sc.nextInt();
        int idx = a[0] - 1;
        Integer[] numbers = new Integer[a[0]];
        int i = 0;
        while (sc.hasNext()) {
          numbers[i] = sc.nextInt();
          i++;
        }
        for (int p=i; p<a[0]; p++) {
          numbers[p] = 9999;
        }
		Arrays.sort(numbers);
        int total = 0;
        for (int q=0; q<a[1]; q++) {
          total = total + numbers[q];
        }
        System.out.println(total);        
    } main {
		Scanner sc = new Scanner(System.in);

        int[] a = new int[2];
        a[0] = sc.nextInt();
        a[1] = sc.nextInt();
        int idx = a[0] - 1;
        Integer[] numbers = new Integer[a[0]];
        int i = 0;
        while (sc.hasNext()) {
          numbers[i] = sc.nextInt();
          i++;
        }
        for (int p=i; p<a[0]; p++) {
          numbers[p] = 9999;
        }
		Arrays.sort(numbers);
        int total = 0;
        for (int q=0; q<a[1]; q++) {
          total = total + numbers[q];
        }
        System.out.println(total);        
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int[] a = new int[2]; a new int[2] 2 a[0] = sc.nextInt() a[0] a 0 sc.nextInt() sc.nextInt sc a[1] = sc.nextInt() a[1] a 1 sc.nextInt() sc.nextInt sc int idx = a[0] - 1; idx a[0] - 1 a[0] a 0 1 Integer[] numbers = new Integer[a[0]]; numbers new Integer[a[0]] a[0] a 0 int i = 0; i 0 while (sc.hasNext()) {
          numbers[i] = sc.nextInt();
          i++;
        } sc.hasNext() sc.hasNext sc {
          numbers[i] = sc.nextInt();
          i++;
        } numbers[i] = sc.nextInt() numbers[i] numbers i sc.nextInt() sc.nextInt sc i++ i for (int p=i; p<a[0]; p++) {
          numbers[p] = 9999;
        } int p=i; int p=i; p i p<a[0] p a[0] a 0 p++ p++ p {
          numbers[p] = 9999;
        } {
          numbers[p] = 9999;
        } numbers[p] = 9999 numbers[p] numbers p 9999 Arrays.sort(numbers) Arrays.sort Arrays numbers int total = 0; total 0 for (int q=0; q<a[1]; q++) {
          total = total + numbers[q];
        } int q=0; int q=0; q 0 q<a[1] q a[1] a 1 q++ q++ q {
          total = total + numbers[q];
        } {
          total = total + numbers[q];
        } total = total + numbers[q] total total + numbers[q] total numbers[q] numbers q System.out.println(total) System.out.println System.out System System.out total String[] args args public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);

        int[] a = new int[2];
        a[0] = sc.nextInt();
        a[1] = sc.nextInt();
        int idx = a[0] - 1;
        Integer[] numbers = new Integer[a[0]];
        int i = 0;
        while (sc.hasNext()) {
          numbers[i] = sc.nextInt();
          i++;
        }
        for (int p=i; p<a[0]; p++) {
          numbers[p] = 9999;
        }
		Arrays.sort(numbers);
        int total = 0;
        for (int q=0; q<a[1]; q++) {
          total = total + numbers[q];
        }
        System.out.println(total);        
    }
} public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);

        int[] a = new int[2];
        a[0] = sc.nextInt();
        a[1] = sc.nextInt();
        int idx = a[0] - 1;
        Integer[] numbers = new Integer[a[0]];
        int i = 0;
        while (sc.hasNext()) {
          numbers[i] = sc.nextInt();
          i++;
        }
        for (int p=i; p<a[0]; p++) {
          numbers[p] = 9999;
        }
		Arrays.sort(numbers);
        int total = 0;
        for (int q=0; q<a[1]; q++) {
          total = total + numbers[q];
        }
        System.out.println(total);        
    }
} Main
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);

        int[] a = new int[2];
        a[0] = sc.nextInt();
        a[1] = sc.nextInt();
        int idx = a[0] - 1;
        Integer[] numbers = new Integer[a[0]];
        int i = 0;
        while (sc.hasNext()) {
          numbers[i] = sc.nextInt();
          i++;
        }
        for (int p=i; p<a[0]; p++) {
          numbers[p] = 9999;
        }
		Arrays.sort(numbers);
        int total = 0;
        for (int q=0; q<a[1]; q++) {
          total = total + numbers[q];
        }
        System.out.println(total);        
    }
}