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

public class Main {
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);

		// 整数の入力
		int a = sc.nextInt();//種類数
		int b = sc.nextInt();//買う数
		
		int[] c = new int[a];
		
		for(int i = 0; i < a; i++) {
			c[i] = sc.nextInt();
		}
		
		Arrays.sort(c);
		
		int d = 0;
		
		for(int i = 0; i < b; i++) {
			d += c[i];
		}
		System.out.println(d);
	}
} 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 a = sc.nextInt();//種類数
		int b = sc.nextInt();//買う数
		
		int[] c = new int[a];
		
		for(int i = 0; i < a; i++) {
			c[i] = sc.nextInt();
		}
		
		Arrays.sort(c);
		
		int d = 0;
		
		for(int i = 0; i < b; i++) {
			d += c[i];
		}
		System.out.println(d);
	}
} Main public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);

		// 整数の入力
		int a = sc.nextInt();//種類数
		int b = sc.nextInt();//買う数
		
		int[] c = new int[a];
		
		for(int i = 0; i < a; i++) {
			c[i] = sc.nextInt();
		}
		
		Arrays.sort(c);
		
		int d = 0;
		
		for(int i = 0; i < b; i++) {
			d += c[i];
		}
		System.out.println(d);
	} main {
		
		Scanner sc = new Scanner(System.in);

		// 整数の入力
		int a = sc.nextInt();//種類数
		int b = sc.nextInt();//買う数
		
		int[] c = new int[a];
		
		for(int i = 0; i < a; i++) {
			c[i] = sc.nextInt();
		}
		
		Arrays.sort(c);
		
		int d = 0;
		
		for(int i = 0; i < b; i++) {
			d += c[i];
		}
		System.out.println(d);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc int b = sc.nextInt(); b sc.nextInt() sc.nextInt sc int[] c = new int[a]; c new int[a] a for(int i = 0; i < a; i++) {
			c[i] = sc.nextInt();
		} int i = 0; int i = 0; i 0 i < a i a i++ i++ i {
			c[i] = sc.nextInt();
		} {
			c[i] = sc.nextInt();
		} c[i] = sc.nextInt() c[i] c i sc.nextInt() sc.nextInt sc Arrays.sort(c) Arrays.sort Arrays c int d = 0; d 0 for(int i = 0; i < b; i++) {
			d += c[i];
		} int i = 0; int i = 0; i 0 i < b i b i++ i++ i {
			d += c[i];
		} {
			d += c[i];
		} d += c[i] d c[i] c i System.out.println(d) System.out.println System.out System System.out d String[] args args public class Main {
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);

		// 整数の入力
		int a = sc.nextInt();//種類数
		int b = sc.nextInt();//買う数
		
		int[] c = new int[a];
		
		for(int i = 0; i < a; i++) {
			c[i] = sc.nextInt();
		}
		
		Arrays.sort(c);
		
		int d = 0;
		
		for(int i = 0; i < b; i++) {
			d += c[i];
		}
		System.out.println(d);
	}
} public class Main {
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);

		// 整数の入力
		int a = sc.nextInt();//種類数
		int b = sc.nextInt();//買う数
		
		int[] c = new int[a];
		
		for(int i = 0; i < a; i++) {
			c[i] = sc.nextInt();
		}
		
		Arrays.sort(c);
		
		int d = 0;
		
		for(int i = 0; i < b; i++) {
			d += c[i];
		}
		System.out.println(d);
	}
} 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 a = sc.nextInt();//種類数
		int b = sc.nextInt();//買う数
		
		int[] c = new int[a];
		
		for(int i = 0; i < a; i++) {
			c[i] = sc.nextInt();
		}
		
		Arrays.sort(c);
		
		int d = 0;
		
		for(int i = 0; i < b; i++) {
			d += c[i];
		}
		System.out.println(d);
	}
}