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

public class Main {
	public static void main(String[] ragas) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();
		ArrayList<Integer> list = new ArrayList<Integer>();
		int count = 0;

		for(int i = 0;i < n;i++) {
			list.add(scan.nextInt());
		}

		Collections.sort(list);

		for(int i = 0;i < k;i++) {
			count += list.get(i);
		}

		System.out.println(count);
	}
} import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util import java.util.Scanner ; Scanner java.util public class Main {
	public static void main(String[] ragas) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();
		ArrayList<Integer> list = new ArrayList<Integer>();
		int count = 0;

		for(int i = 0;i < n;i++) {
			list.add(scan.nextInt());
		}

		Collections.sort(list);

		for(int i = 0;i < k;i++) {
			count += list.get(i);
		}

		System.out.println(count);
	}
} Main public static void main(String[] ragas) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();
		ArrayList<Integer> list = new ArrayList<Integer>();
		int count = 0;

		for(int i = 0;i < n;i++) {
			list.add(scan.nextInt());
		}

		Collections.sort(list);

		for(int i = 0;i < k;i++) {
			count += list.get(i);
		}

		System.out.println(count);
	} main {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();
		ArrayList<Integer> list = new ArrayList<Integer>();
		int count = 0;

		for(int i = 0;i < n;i++) {
			list.add(scan.nextInt());
		}

		Collections.sort(list);

		for(int i = 0;i < k;i++) {
			count += list.get(i);
		}

		System.out.println(count);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan int k = scan.nextInt(); k scan.nextInt() scan.nextInt scan ArrayList<Integer> list = new ArrayList<Integer>(); list new ArrayList<Integer>() int count = 0; count 0 for(int i = 0;i < n;i++) {
			list.add(scan.nextInt());
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			list.add(scan.nextInt());
		} {
			list.add(scan.nextInt());
		} list.add(scan.nextInt()) list.add list scan.nextInt() scan.nextInt scan Collections.sort(list) Collections.sort Collections list for(int i = 0;i < k;i++) {
			count += list.get(i);
		} int i = 0; int i = 0; i 0 i < k i k i++ i++ i {
			count += list.get(i);
		} {
			count += list.get(i);
		} count += list.get(i) count list.get(i) list.get list i System.out.println(count) System.out.println System.out System System.out count String[] ragas ragas public class Main {
	public static void main(String[] ragas) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();
		ArrayList<Integer> list = new ArrayList<Integer>();
		int count = 0;

		for(int i = 0;i < n;i++) {
			list.add(scan.nextInt());
		}

		Collections.sort(list);

		for(int i = 0;i < k;i++) {
			count += list.get(i);
		}

		System.out.println(count);
	}
} public class Main {
	public static void main(String[] ragas) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();
		ArrayList<Integer> list = new ArrayList<Integer>();
		int count = 0;

		for(int i = 0;i < n;i++) {
			list.add(scan.nextInt());
		}

		Collections.sort(list);

		for(int i = 0;i < k;i++) {
			count += list.get(i);
		}

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

public class Main {
	public static void main(String[] ragas) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();
		ArrayList<Integer> list = new ArrayList<Integer>();
		int count = 0;

		for(int i = 0;i < n;i++) {
			list.add(scan.nextInt());
		}

		Collections.sort(list);

		for(int i = 0;i < k;i++) {
			count += list.get(i);
		}

		System.out.println(count);
	}
}
