import 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();
		Integer tree[] = new Integer[n];
		for (int i = 0; i < n; i++) {
            tree[i] = sc.nextInt();
		}		
		Arrays.sort(tree);
		int r = 0;
		for (int j = 0; j < k; j++) {
			r = r + tree[j];
		}
	  System.out.println(r);
	  sc.close();
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		Integer tree[] = new Integer[n];
		for (int i = 0; i < n; i++) {
            tree[i] = sc.nextInt();
		}		
		Arrays.sort(tree);
		int r = 0;
		for (int j = 0; j < k; j++) {
			r = r + tree[j];
		}
	  System.out.println(r);
	  sc.close();
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		Integer tree[] = new Integer[n];
		for (int i = 0; i < n; i++) {
            tree[i] = sc.nextInt();
		}		
		Arrays.sort(tree);
		int r = 0;
		for (int j = 0; j < k; j++) {
			r = r + tree[j];
		}
	  System.out.println(r);
	  sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		Integer tree[] = new Integer[n];
		for (int i = 0; i < n; i++) {
            tree[i] = sc.nextInt();
		}		
		Arrays.sort(tree);
		int r = 0;
		for (int j = 0; j < k; j++) {
			r = r + tree[j];
		}
	  System.out.println(r);
	  sc.close();
	} 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 Integer tree[] = new Integer[n]; tree new Integer[n] n for (int i = 0; i < n; i++) {
            tree[i] = sc.nextInt();
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            tree[i] = sc.nextInt();
		} {
            tree[i] = sc.nextInt();
		} tree[i] = sc.nextInt() tree[i] tree i sc.nextInt() sc.nextInt sc Arrays.sort(tree) Arrays.sort Arrays tree int r = 0; r 0 for (int j = 0; j < k; j++) {
			r = r + tree[j];
		} int j = 0; int j = 0; j 0 j < k j k j++ j++ j {
			r = r + tree[j];
		} {
			r = r + tree[j];
		} r = r + tree[j] r r + tree[j] r tree[j] tree j System.out.println(r) System.out.println System.out System System.out r sc.close() sc.close sc 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();
		Integer tree[] = new Integer[n];
		for (int i = 0; i < n; i++) {
            tree[i] = sc.nextInt();
		}		
		Arrays.sort(tree);
		int r = 0;
		for (int j = 0; j < k; j++) {
			r = r + tree[j];
		}
	  System.out.println(r);
	  sc.close();
	}
} public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		Integer tree[] = new Integer[n];
		for (int i = 0; i < n; i++) {
            tree[i] = sc.nextInt();
		}		
		Arrays.sort(tree);
		int r = 0;
		for (int j = 0; j < k; j++) {
			r = r + tree[j];
		}
	  System.out.println(r);
	  sc.close();
	}
} Main
import 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();
		Integer tree[] = new Integer[n];
		for (int i = 0; i < n; i++) {
            tree[i] = sc.nextInt();
		}		
		Arrays.sort(tree);
		int r = 0;
		for (int j = 0; j < k; j++) {
			r = r + tree[j];
		}
	  System.out.println(r);
	  sc.close();
	}
}