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