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

public class Main{
	public static void main(String[] args)throws Exception {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int sum = 0;
		int array[] = new int[a];

		for(int i = 0;i < a; i++) {
			array[i] = scan.nextInt();
		}
		Arrays.sort(array);
		for(int i = 0;i < b;i++) {
			sum += array[i];
		}
		System.out.println(sum);
		scan.close();
	}
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main{
	public static void main(String[] args)throws Exception {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int sum = 0;
		int array[] = new int[a];

		for(int i = 0;i < a; i++) {
			array[i] = scan.nextInt();
		}
		Arrays.sort(array);
		for(int i = 0;i < b;i++) {
			sum += array[i];
		}
		System.out.println(sum);
		scan.close();
	}
} Main public static void main(String[] args)throws Exception {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int sum = 0;
		int array[] = new int[a];

		for(int i = 0;i < a; i++) {
			array[i] = scan.nextInt();
		}
		Arrays.sort(array);
		for(int i = 0;i < b;i++) {
			sum += array[i];
		}
		System.out.println(sum);
		scan.close();
	} main {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int sum = 0;
		int array[] = new int[a];

		for(int i = 0;i < a; i++) {
			array[i] = scan.nextInt();
		}
		Arrays.sort(array);
		for(int i = 0;i < b;i++) {
			sum += array[i];
		}
		System.out.println(sum);
		scan.close();
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int a = scan.nextInt(); a scan.nextInt() scan.nextInt scan int b = scan.nextInt(); b scan.nextInt() scan.nextInt scan int sum = 0; sum 0 int array[] = new int[a]; array new int[a] a for(int i = 0;i < a; i++) {
			array[i] = scan.nextInt();
		} int i = 0; int i = 0; i 0 i < a i a i++ i++ i {
			array[i] = scan.nextInt();
		} {
			array[i] = scan.nextInt();
		} array[i] = scan.nextInt() array[i] array i scan.nextInt() scan.nextInt scan Arrays.sort(array) Arrays.sort Arrays array for(int i = 0;i < b;i++) {
			sum += array[i];
		} int i = 0; int i = 0; i 0 i < b i b i++ i++ i {
			sum += array[i];
		} {
			sum += array[i];
		} sum += array[i] sum array[i] array i System.out.println(sum) System.out.println System.out System System.out sum scan.close() scan.close scan String[] args args public class Main{
	public static void main(String[] args)throws Exception {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int sum = 0;
		int array[] = new int[a];

		for(int i = 0;i < a; i++) {
			array[i] = scan.nextInt();
		}
		Arrays.sort(array);
		for(int i = 0;i < b;i++) {
			sum += array[i];
		}
		System.out.println(sum);
		scan.close();
	}
} public class Main{
	public static void main(String[] args)throws Exception {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int sum = 0;
		int array[] = new int[a];

		for(int i = 0;i < a; i++) {
			array[i] = scan.nextInt();
		}
		Arrays.sort(array);
		for(int i = 0;i < b;i++) {
			sum += array[i];
		}
		System.out.println(sum);
		scan.close();
	}
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	public static void main(String[] args)throws Exception {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int sum = 0;
		int array[] = new int[a];

		for(int i = 0;i < a; i++) {
			array[i] = scan.nextInt();
		}
		Arrays.sort(array);
		for(int i = 0;i < b;i++) {
			sum += array[i];
		}
		System.out.println(sum);
		scan.close();
	}
}