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

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		//数取得
		int N = sc.nextInt();
		int K = sc.nextInt();

		ArrayList<Integer> priceList = new ArrayList<>();

		for(int i = 0; i < N; i++) {
			int num = sc.nextInt();
			priceList.add(num);
		}

		sc.close();

		Collections.sort(priceList);

		int answer = 0;

		for(int i = 0; i < K; i++) {
			answer += priceList.get(i);
		}

		System.out.println(answer);

	}

} 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 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		//数取得
		int N = sc.nextInt();
		int K = sc.nextInt();

		ArrayList<Integer> priceList = new ArrayList<>();

		for(int i = 0; i < N; i++) {
			int num = sc.nextInt();
			priceList.add(num);
		}

		sc.close();

		Collections.sort(priceList);

		int answer = 0;

		for(int i = 0; i < K; i++) {
			answer += priceList.get(i);
		}

		System.out.println(answer);

	}

} Main public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		//数取得
		int N = sc.nextInt();
		int K = sc.nextInt();

		ArrayList<Integer> priceList = new ArrayList<>();

		for(int i = 0; i < N; i++) {
			int num = sc.nextInt();
			priceList.add(num);
		}

		sc.close();

		Collections.sort(priceList);

		int answer = 0;

		for(int i = 0; i < K; i++) {
			answer += priceList.get(i);
		}

		System.out.println(answer);

	} main {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		//数取得
		int N = sc.nextInt();
		int K = sc.nextInt();

		ArrayList<Integer> priceList = new ArrayList<>();

		for(int i = 0; i < N; i++) {
			int num = sc.nextInt();
			priceList.add(num);
		}

		sc.close();

		Collections.sort(priceList);

		int answer = 0;

		for(int i = 0; i < K; i++) {
			answer += priceList.get(i);
		}

		System.out.println(answer);

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int K = sc.nextInt(); K sc.nextInt() sc.nextInt sc ArrayList<Integer> priceList = new ArrayList<>(); priceList new ArrayList<>() for(int i = 0; i < N; i++) {
			int num = sc.nextInt();
			priceList.add(num);
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			int num = sc.nextInt();
			priceList.add(num);
		} {
			int num = sc.nextInt();
			priceList.add(num);
		} int num = sc.nextInt(); num sc.nextInt() sc.nextInt sc priceList.add(num) priceList.add priceList num sc.close() sc.close sc Collections.sort(priceList) Collections.sort Collections priceList int answer = 0; answer 0 for(int i = 0; i < K; i++) {
			answer += priceList.get(i);
		} int i = 0; int i = 0; i 0 i < K i K i++ i++ i {
			answer += priceList.get(i);
		} {
			answer += priceList.get(i);
		} answer += priceList.get(i) answer priceList.get(i) priceList.get priceList i System.out.println(answer) System.out.println System.out System System.out answer String[] args args public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		//数取得
		int N = sc.nextInt();
		int K = sc.nextInt();

		ArrayList<Integer> priceList = new ArrayList<>();

		for(int i = 0; i < N; i++) {
			int num = sc.nextInt();
			priceList.add(num);
		}

		sc.close();

		Collections.sort(priceList);

		int answer = 0;

		for(int i = 0; i < K; i++) {
			answer += priceList.get(i);
		}

		System.out.println(answer);

	}

} public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		//数取得
		int N = sc.nextInt();
		int K = sc.nextInt();

		ArrayList<Integer> priceList = new ArrayList<>();

		for(int i = 0; i < N; i++) {
			int num = sc.nextInt();
			priceList.add(num);
		}

		sc.close();

		Collections.sort(priceList);

		int answer = 0;

		for(int i = 0; i < K; i++) {
			answer += priceList.get(i);
		}

		System.out.println(answer);

	}

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

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		//数取得
		int N = sc.nextInt();
		int K = sc.nextInt();

		ArrayList<Integer> priceList = new ArrayList<>();

		for(int i = 0; i < N; i++) {
			int num = sc.nextInt();
			priceList.add(num);
		}

		sc.close();

		Collections.sort(priceList);

		int answer = 0;

		for(int i = 0; i < K; i++) {
			answer += priceList.get(i);
		}

		System.out.println(answer);

	}

}
