import java.util.*;
import java.math.*;
public class Main {
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
     
        List<Integer> a = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            int d = sc.nextInt();
			a.add(d);
            }
        Collections.sort(a);
			
		int price = 0;
		for (int j = 0; j < K; j++) {
			price += a.get(j);
		}
		System.out.println(price);
        }
		
} import java.util.*; util.* java import java.math.*; math.* java public class Main {
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
     
        List<Integer> a = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            int d = sc.nextInt();
			a.add(d);
            }
        Collections.sort(a);
			
		int price = 0;
		for (int j = 0; j < K; j++) {
			price += a.get(j);
		}
		System.out.println(price);
        }
		
} Main public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
     
        List<Integer> a = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            int d = sc.nextInt();
			a.add(d);
            }
        Collections.sort(a);
			
		int price = 0;
		for (int j = 0; j < K; j++) {
			price += a.get(j);
		}
		System.out.println(price);
        } main {
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
     
        List<Integer> a = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            int d = sc.nextInt();
			a.add(d);
            }
        Collections.sort(a);
			
		int price = 0;
		for (int j = 0; j < K; j++) {
			price += a.get(j);
		}
		System.out.println(price);
        } 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 List<Integer> a = new ArrayList<>(); a new ArrayList<>() for (int i = 0; i < N; i++) {
            int d = sc.nextInt();
			a.add(d);
            } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            int d = sc.nextInt();
			a.add(d);
            } {
            int d = sc.nextInt();
			a.add(d);
            } int d = sc.nextInt(); d sc.nextInt() sc.nextInt sc a.add(d) a.add a d Collections.sort(a) Collections.sort Collections a int price = 0; price 0 for (int j = 0; j < K; j++) {
			price += a.get(j);
		} int j = 0; int j = 0; j 0 j < K j K j++ j++ j {
			price += a.get(j);
		} {
			price += a.get(j);
		} price += a.get(j) price a.get(j) a.get a j System.out.println(price) System.out.println System.out System System.out price 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();
     
        List<Integer> a = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            int d = sc.nextInt();
			a.add(d);
            }
        Collections.sort(a);
			
		int price = 0;
		for (int j = 0; j < K; j++) {
			price += a.get(j);
		}
		System.out.println(price);
        }
		
} public class Main {
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
     
        List<Integer> a = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            int d = sc.nextInt();
			a.add(d);
            }
        Collections.sort(a);
			
		int price = 0;
		for (int j = 0; j < K; j++) {
			price += a.get(j);
		}
		System.out.println(price);
        }
		
} Main
import java.util.*;
import java.math.*;
public class Main {
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
     
        List<Integer> a = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            int d = sc.nextInt();
			a.add(d);
            }
        Collections.sort(a);
			
		int price = 0;
		for (int j = 0; j < K; j++) {
			price += a.get(j);
		}
		System.out.println(price);
        }
		
}