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

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int t = scan.nextInt();
		int[] arr = new int[t];
		int type = scan.nextInt();
		for (int count = 0; count < t; count++)
			arr[count] = scan.nextInt();
		Arrays.sort(arr); int sum = 0;
		for (int count = 0; count < type; count++)
			sum += arr[count];
		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) {
		Scanner scan = new Scanner(System.in);
		int t = scan.nextInt();
		int[] arr = new int[t];
		int type = scan.nextInt();
		for (int count = 0; count < t; count++)
			arr[count] = scan.nextInt();
		Arrays.sort(arr); int sum = 0;
		for (int count = 0; count < type; count++)
			sum += arr[count];
		System.out.println(sum);
		scan.close();
	}
} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int t = scan.nextInt();
		int[] arr = new int[t];
		int type = scan.nextInt();
		for (int count = 0; count < t; count++)
			arr[count] = scan.nextInt();
		Arrays.sort(arr); int sum = 0;
		for (int count = 0; count < type; count++)
			sum += arr[count];
		System.out.println(sum);
		scan.close();
	} main {
		Scanner scan = new Scanner(System.in);
		int t = scan.nextInt();
		int[] arr = new int[t];
		int type = scan.nextInt();
		for (int count = 0; count < t; count++)
			arr[count] = scan.nextInt();
		Arrays.sort(arr); int sum = 0;
		for (int count = 0; count < type; count++)
			sum += arr[count];
		System.out.println(sum);
		scan.close();
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int t = scan.nextInt(); t scan.nextInt() scan.nextInt scan int[] arr = new int[t]; arr new int[t] t int type = scan.nextInt(); type scan.nextInt() scan.nextInt scan for (int count = 0; count < t; count++)
			arr[count] = scan.nextInt(); int count = 0; int count = 0; count 0 count < t count t count++ count++ count arr[count] = scan.nextInt(); arr[count] = scan.nextInt() arr[count] arr count scan.nextInt() scan.nextInt scan Arrays.sort(arr) Arrays.sort Arrays arr int sum = 0; sum 0 for (int count = 0; count < type; count++)
			sum += arr[count]; int count = 0; int count = 0; count 0 count < type count type count++ count++ count sum += arr[count]; sum += arr[count] sum arr[count] arr count 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) {
		Scanner scan = new Scanner(System.in);
		int t = scan.nextInt();
		int[] arr = new int[t];
		int type = scan.nextInt();
		for (int count = 0; count < t; count++)
			arr[count] = scan.nextInt();
		Arrays.sort(arr); int sum = 0;
		for (int count = 0; count < type; count++)
			sum += arr[count];
		System.out.println(sum);
		scan.close();
	}
} public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int t = scan.nextInt();
		int[] arr = new int[t];
		int type = scan.nextInt();
		for (int count = 0; count < t; count++)
			arr[count] = scan.nextInt();
		Arrays.sort(arr); int sum = 0;
		for (int count = 0; count < type; count++)
			sum += arr[count];
		System.out.println(sum);
		scan.close();
	}
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int t = scan.nextInt();
		int[] arr = new int[t];
		int type = scan.nextInt();
		for (int count = 0; count < t; count++)
			arr[count] = scan.nextInt();
		Arrays.sort(arr); int sum = 0;
		for (int count = 0; count < type; count++)
			sum += arr[count];
		System.out.println(sum);
		scan.close();
	}
}
