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

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner kb = new Scanner(System.in);
		int n = kb.nextInt();
		int k = kb.nextInt();
		int count = 0;
		ArrayList<Integer> a = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			int p = kb.nextInt();
			a.add(p);
		}
		Collections.sort(a);
		for (int i = 0; i < k; i++) {
			count += a.get(i);
		}

		System.out.println(count);

		kb.close();
	}

} 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[] args) {
		// TODO Auto-generated method stub
		Scanner kb = new Scanner(System.in);
		int n = kb.nextInt();
		int k = kb.nextInt();
		int count = 0;
		ArrayList<Integer> a = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			int p = kb.nextInt();
			a.add(p);
		}
		Collections.sort(a);
		for (int i = 0; i < k; i++) {
			count += a.get(i);
		}

		System.out.println(count);

		kb.close();
	}

} Main public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner kb = new Scanner(System.in);
		int n = kb.nextInt();
		int k = kb.nextInt();
		int count = 0;
		ArrayList<Integer> a = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			int p = kb.nextInt();
			a.add(p);
		}
		Collections.sort(a);
		for (int i = 0; i < k; i++) {
			count += a.get(i);
		}

		System.out.println(count);

		kb.close();
	} main {
		// TODO Auto-generated method stub
		Scanner kb = new Scanner(System.in);
		int n = kb.nextInt();
		int k = kb.nextInt();
		int count = 0;
		ArrayList<Integer> a = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			int p = kb.nextInt();
			a.add(p);
		}
		Collections.sort(a);
		for (int i = 0; i < k; i++) {
			count += a.get(i);
		}

		System.out.println(count);

		kb.close();
	} Scanner kb = new Scanner(System.in); kb new Scanner(System.in) int n = kb.nextInt(); n kb.nextInt() kb.nextInt kb int k = kb.nextInt(); k kb.nextInt() kb.nextInt kb int count = 0; count 0 ArrayList<Integer> a = new ArrayList<>(); a new ArrayList<>() for (int i = 0; i < n; i++) {
			int p = kb.nextInt();
			a.add(p);
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			int p = kb.nextInt();
			a.add(p);
		} {
			int p = kb.nextInt();
			a.add(p);
		} int p = kb.nextInt(); p kb.nextInt() kb.nextInt kb a.add(p) a.add a p Collections.sort(a) Collections.sort Collections a for (int i = 0; i < k; i++) {
			count += a.get(i);
		} int i = 0; int i = 0; i 0 i < k i k i++ i++ i {
			count += a.get(i);
		} {
			count += a.get(i);
		} count += a.get(i) count a.get(i) a.get a i System.out.println(count) System.out.println System.out System System.out count kb.close() kb.close kb String[] args args public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner kb = new Scanner(System.in);
		int n = kb.nextInt();
		int k = kb.nextInt();
		int count = 0;
		ArrayList<Integer> a = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			int p = kb.nextInt();
			a.add(p);
		}
		Collections.sort(a);
		for (int i = 0; i < k; i++) {
			count += a.get(i);
		}

		System.out.println(count);

		kb.close();
	}

} public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner kb = new Scanner(System.in);
		int n = kb.nextInt();
		int k = kb.nextInt();
		int count = 0;
		ArrayList<Integer> a = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			int p = kb.nextInt();
			a.add(p);
		}
		Collections.sort(a);
		for (int i = 0; i < k; i++) {
			count += a.get(i);
		}

		System.out.println(count);

		kb.close();
	}

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

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner kb = new Scanner(System.in);
		int n = kb.nextInt();
		int k = kb.nextInt();
		int count = 0;
		ArrayList<Integer> a = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			int p = kb.nextInt();
			a.add(p);
		}
		Collections.sort(a);
		for (int i = 0; i < k; i++) {
			count += a.get(i);
		}

		System.out.println(count);

		kb.close();
	}

}
