import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

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

			String[] arr1 = data1.split(" ");
			String[] arr2 = data2.split(" ");

			int syurui = Integer.parseInt(arr1[0]);
			int sentaku = Integer.parseInt(arr1[1]);

			List<Integer> list = new ArrayList<Integer>();
			for (String str : arr2) {
				list.add(Integer.parseInt(str));
			}

			Collections.sort(list);

			int total = 0;
			for (int i = 0; i < sentaku; i++) {
				total += list.get(i);
			}

			System.out.println(total);
		}
	}
} import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util public class Main {

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

			String[] arr1 = data1.split(" ");
			String[] arr2 = data2.split(" ");

			int syurui = Integer.parseInt(arr1[0]);
			int sentaku = Integer.parseInt(arr1[1]);

			List<Integer> list = new ArrayList<Integer>();
			for (String str : arr2) {
				list.add(Integer.parseInt(str));
			}

			Collections.sort(list);

			int total = 0;
			for (int i = 0; i < sentaku; i++) {
				total += list.get(i);
			}

			System.out.println(total);
		}
	}
} Main public static void main(String[] args) {
		try(Scanner scanner = new Scanner(System.in)) {
			String data1 = scanner.nextLine();
			String data2 = scanner.nextLine();

			String[] arr1 = data1.split(" ");
			String[] arr2 = data2.split(" ");

			int syurui = Integer.parseInt(arr1[0]);
			int sentaku = Integer.parseInt(arr1[1]);

			List<Integer> list = new ArrayList<Integer>();
			for (String str : arr2) {
				list.add(Integer.parseInt(str));
			}

			Collections.sort(list);

			int total = 0;
			for (int i = 0; i < sentaku; i++) {
				total += list.get(i);
			}

			System.out.println(total);
		}
	} main {
		try(Scanner scanner = new Scanner(System.in)) {
			String data1 = scanner.nextLine();
			String data2 = scanner.nextLine();

			String[] arr1 = data1.split(" ");
			String[] arr2 = data2.split(" ");

			int syurui = Integer.parseInt(arr1[0]);
			int sentaku = Integer.parseInt(arr1[1]);

			List<Integer> list = new ArrayList<Integer>();
			for (String str : arr2) {
				list.add(Integer.parseInt(str));
			}

			Collections.sort(list);

			int total = 0;
			for (int i = 0; i < sentaku; i++) {
				total += list.get(i);
			}

			System.out.println(total);
		}
	} try(Scanner scanner = new Scanner(System.in)) {
			String data1 = scanner.nextLine();
			String data2 = scanner.nextLine();

			String[] arr1 = data1.split(" ");
			String[] arr2 = data2.split(" ");

			int syurui = Integer.parseInt(arr1[0]);
			int sentaku = Integer.parseInt(arr1[1]);

			List<Integer> list = new ArrayList<Integer>();
			for (String str : arr2) {
				list.add(Integer.parseInt(str));
			}

			Collections.sort(list);

			int total = 0;
			for (int i = 0; i < sentaku; i++) {
				total += list.get(i);
			}

			System.out.println(total);
		} {
			String data1 = scanner.nextLine();
			String data2 = scanner.nextLine();

			String[] arr1 = data1.split(" ");
			String[] arr2 = data2.split(" ");

			int syurui = Integer.parseInt(arr1[0]);
			int sentaku = Integer.parseInt(arr1[1]);

			List<Integer> list = new ArrayList<Integer>();
			for (String str : arr2) {
				list.add(Integer.parseInt(str));
			}

			Collections.sort(list);

			int total = 0;
			for (int i = 0; i < sentaku; i++) {
				total += list.get(i);
			}

			System.out.println(total);
		} Scanner scanner = new Scanner(System.in) Scanner scanner = new Scanner(System.in) new Scanner(System.in) String data1 = scanner.nextLine(); data1 scanner.nextLine() scanner.nextLine scanner String data2 = scanner.nextLine(); data2 scanner.nextLine() scanner.nextLine scanner String[] arr1 = data1.split(" "); arr1 data1.split(" ") data1.split data1 " " String[] arr2 = data2.split(" "); arr2 data2.split(" ") data2.split data2 " " int syurui = Integer.parseInt(arr1[0]); syurui Integer.parseInt(arr1[0]) Integer.parseInt Integer arr1[0] arr1 0 int sentaku = Integer.parseInt(arr1[1]); sentaku Integer.parseInt(arr1[1]) Integer.parseInt Integer arr1[1] arr1 1 List<Integer> list = new ArrayList<Integer>(); list new ArrayList<Integer>() for (String str : arr2) {
				list.add(Integer.parseInt(str));
			} String str arr2 {
				list.add(Integer.parseInt(str));
			} {
				list.add(Integer.parseInt(str));
			} list.add(Integer.parseInt(str)) list.add list Integer.parseInt(str) Integer.parseInt Integer str Collections.sort(list) Collections.sort Collections list int total = 0; total 0 for (int i = 0; i < sentaku; i++) {
				total += list.get(i);
			} int i = 0; int i = 0; i 0 i < sentaku i sentaku i++ i++ i {
				total += list.get(i);
			} {
				total += list.get(i);
			} total += list.get(i) total list.get(i) list.get list i System.out.println(total) System.out.println System.out System System.out total String[] args args public class Main {

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

			String[] arr1 = data1.split(" ");
			String[] arr2 = data2.split(" ");

			int syurui = Integer.parseInt(arr1[0]);
			int sentaku = Integer.parseInt(arr1[1]);

			List<Integer> list = new ArrayList<Integer>();
			for (String str : arr2) {
				list.add(Integer.parseInt(str));
			}

			Collections.sort(list);

			int total = 0;
			for (int i = 0; i < sentaku; i++) {
				total += list.get(i);
			}

			System.out.println(total);
		}
	}
} public class Main {

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

			String[] arr1 = data1.split(" ");
			String[] arr2 = data2.split(" ");

			int syurui = Integer.parseInt(arr1[0]);
			int sentaku = Integer.parseInt(arr1[1]);

			List<Integer> list = new ArrayList<Integer>();
			for (String str : arr2) {
				list.add(Integer.parseInt(str));
			}

			Collections.sort(list);

			int total = 0;
			for (int i = 0; i < sentaku; i++) {
				total += list.get(i);
			}

			System.out.println(total);
		}
	}
} Main
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

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

			String[] arr1 = data1.split(" ");
			String[] arr2 = data2.split(" ");

			int syurui = Integer.parseInt(arr1[0]);
			int sentaku = Integer.parseInt(arr1[1]);

			List<Integer> list = new ArrayList<Integer>();
			for (String str : arr2) {
				list.add(Integer.parseInt(str));
			}

			Collections.sort(list);

			int total = 0;
			for (int i = 0; i < sentaku; i++) {
				total += list.get(i);
			}

			System.out.println(total);
		}
	}
}