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

public class Main {

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

		String[] nk = scanner.nextLine().split(" ");
		int n = Integer.parseInt(nk[0]);
		int k = Integer.parseInt(nk[1]);

		int[] ar = new int[n];

		for (int i = 0; i < n; i++) {
			ar[i] = scanner.nextInt();
		}

		Arrays.sort(ar);

		int sum = 0;
		for (int i = 0; i < k; i++) {
			sum += ar[i];
		}

		System.out.println(sum);

	}

} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {

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

		String[] nk = scanner.nextLine().split(" ");
		int n = Integer.parseInt(nk[0]);
		int k = Integer.parseInt(nk[1]);

		int[] ar = new int[n];

		for (int i = 0; i < n; i++) {
			ar[i] = scanner.nextInt();
		}

		Arrays.sort(ar);

		int sum = 0;
		for (int i = 0; i < k; i++) {
			sum += ar[i];
		}

		System.out.println(sum);

	}

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

		String[] nk = scanner.nextLine().split(" ");
		int n = Integer.parseInt(nk[0]);
		int k = Integer.parseInt(nk[1]);

		int[] ar = new int[n];

		for (int i = 0; i < n; i++) {
			ar[i] = scanner.nextInt();
		}

		Arrays.sort(ar);

		int sum = 0;
		for (int i = 0; i < k; i++) {
			sum += ar[i];
		}

		System.out.println(sum);

	} main {
		Scanner scanner = new Scanner(System.in);

		String[] nk = scanner.nextLine().split(" ");
		int n = Integer.parseInt(nk[0]);
		int k = Integer.parseInt(nk[1]);

		int[] ar = new int[n];

		for (int i = 0; i < n; i++) {
			ar[i] = scanner.nextInt();
		}

		Arrays.sort(ar);

		int sum = 0;
		for (int i = 0; i < k; i++) {
			sum += ar[i];
		}

		System.out.println(sum);

	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) String[] nk = scanner.nextLine().split(" "); nk scanner.nextLine().split(" ") scanner.nextLine().split scanner.nextLine() scanner.nextLine scanner " " int n = Integer.parseInt(nk[0]); n Integer.parseInt(nk[0]) Integer.parseInt Integer nk[0] nk 0 int k = Integer.parseInt(nk[1]); k Integer.parseInt(nk[1]) Integer.parseInt Integer nk[1] nk 1 int[] ar = new int[n]; ar new int[n] n for (int i = 0; i < n; i++) {
			ar[i] = scanner.nextInt();
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			ar[i] = scanner.nextInt();
		} {
			ar[i] = scanner.nextInt();
		} ar[i] = scanner.nextInt() ar[i] ar i scanner.nextInt() scanner.nextInt scanner Arrays.sort(ar) Arrays.sort Arrays ar int sum = 0; sum 0 for (int i = 0; i < k; i++) {
			sum += ar[i];
		} int i = 0; int i = 0; i 0 i < k i k i++ i++ i {
			sum += ar[i];
		} {
			sum += ar[i];
		} sum += ar[i] sum ar[i] ar i 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 scanner = new Scanner(System.in);

		String[] nk = scanner.nextLine().split(" ");
		int n = Integer.parseInt(nk[0]);
		int k = Integer.parseInt(nk[1]);

		int[] ar = new int[n];

		for (int i = 0; i < n; i++) {
			ar[i] = scanner.nextInt();
		}

		Arrays.sort(ar);

		int sum = 0;
		for (int i = 0; i < k; i++) {
			sum += ar[i];
		}

		System.out.println(sum);

	}

} public class Main {

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

		String[] nk = scanner.nextLine().split(" ");
		int n = Integer.parseInt(nk[0]);
		int k = Integer.parseInt(nk[1]);

		int[] ar = new int[n];

		for (int i = 0; i < n; i++) {
			ar[i] = scanner.nextInt();
		}

		Arrays.sort(ar);

		int sum = 0;
		for (int i = 0; i < k; i++) {
			sum += ar[i];
		}

		System.out.println(sum);

	}

} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

		String[] nk = scanner.nextLine().split(" ");
		int n = Integer.parseInt(nk[0]);
		int k = Integer.parseInt(nk[1]);

		int[] ar = new int[n];

		for (int i = 0; i < n; i++) {
			ar[i] = scanner.nextInt();
		}

		Arrays.sort(ar);

		int sum = 0;
		for (int i = 0; i < k; i++) {
			sum += ar[i];
		}

		System.out.println(sum);

	}

}