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

	public class Main{

		public static void main(String[] args){

			Scanner sc = new Scanner(System.in);
			int type = sc.nextInt();
			int buy = sc.nextInt();
			int typeArray[] = new int[type];

			for(int i=0; i<typeArray.length; i++){
				typeArray[i]=sc.nextInt();
			}
			Arrays.sort(typeArray);

			int sum =0;
			for(int j=0; j<buy; j++){
				sum = sum + typeArray[j];
		}
		System.out.println(sum);
	}
} 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 type = sc.nextInt();
			int buy = sc.nextInt();
			int typeArray[] = new int[type];

			for(int i=0; i<typeArray.length; i++){
				typeArray[i]=sc.nextInt();
			}
			Arrays.sort(typeArray);

			int sum =0;
			for(int j=0; j<buy; j++){
				sum = sum + typeArray[j];
		}
		System.out.println(sum);
	}
} Main public static void main(String[] args){

			Scanner sc = new Scanner(System.in);
			int type = sc.nextInt();
			int buy = sc.nextInt();
			int typeArray[] = new int[type];

			for(int i=0; i<typeArray.length; i++){
				typeArray[i]=sc.nextInt();
			}
			Arrays.sort(typeArray);

			int sum =0;
			for(int j=0; j<buy; j++){
				sum = sum + typeArray[j];
		}
		System.out.println(sum);
	} main {

			Scanner sc = new Scanner(System.in);
			int type = sc.nextInt();
			int buy = sc.nextInt();
			int typeArray[] = new int[type];

			for(int i=0; i<typeArray.length; i++){
				typeArray[i]=sc.nextInt();
			}
			Arrays.sort(typeArray);

			int sum =0;
			for(int j=0; j<buy; j++){
				sum = sum + typeArray[j];
		}
		System.out.println(sum);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int type = sc.nextInt(); type sc.nextInt() sc.nextInt sc int buy = sc.nextInt(); buy sc.nextInt() sc.nextInt sc int typeArray[] = new int[type]; typeArray new int[type] type for(int i=0; i<typeArray.length; i++){
				typeArray[i]=sc.nextInt();
			} int i=0; int i=0; i 0 i<typeArray.length i typeArray.length typeArray typeArray.length i++ i++ i {
				typeArray[i]=sc.nextInt();
			} {
				typeArray[i]=sc.nextInt();
			} typeArray[i]=sc.nextInt() typeArray[i] typeArray i sc.nextInt() sc.nextInt sc Arrays.sort(typeArray) Arrays.sort Arrays typeArray int sum =0; sum 0 for(int j=0; j<buy; j++){
				sum = sum + typeArray[j];
		} int j=0; int j=0; j 0 j<buy j buy j++ j++ j {
				sum = sum + typeArray[j];
		} {
				sum = sum + typeArray[j];
		} sum = sum + typeArray[j] sum sum + typeArray[j] sum typeArray[j] typeArray j System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main{

		public static void main(String[] args){

			Scanner sc = new Scanner(System.in);
			int type = sc.nextInt();
			int buy = sc.nextInt();
			int typeArray[] = new int[type];

			for(int i=0; i<typeArray.length; i++){
				typeArray[i]=sc.nextInt();
			}
			Arrays.sort(typeArray);

			int sum =0;
			for(int j=0; j<buy; j++){
				sum = sum + typeArray[j];
		}
		System.out.println(sum);
	}
} public class Main{

		public static void main(String[] args){

			Scanner sc = new Scanner(System.in);
			int type = sc.nextInt();
			int buy = sc.nextInt();
			int typeArray[] = new int[type];

			for(int i=0; i<typeArray.length; i++){
				typeArray[i]=sc.nextInt();
			}
			Arrays.sort(typeArray);

			int sum =0;
			for(int j=0; j<buy; j++){
				sum = sum + typeArray[j];
		}
		System.out.println(sum);
	}
} 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 type = sc.nextInt();
			int buy = sc.nextInt();
			int typeArray[] = new int[type];

			for(int i=0; i<typeArray.length; i++){
				typeArray[i]=sc.nextInt();
			}
			Arrays.sort(typeArray);

			int sum =0;
			for(int j=0; j<buy; j++){
				sum = sum + typeArray[j];
		}
		System.out.println(sum);
	}
}
