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

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] lines = line.split(" ");
		int N = Integer.parseInt(lines[0]);
		int K = Integer.parseInt(lines[1]);

		int[] fruit = new int[N];

		line = sc.nextLine();
		lines = line.split(" ");
		for(int i = 0; i < N; i++) {
			fruit[i] = Integer.parseInt(lines[i]);
		}
		Arrays.sort(fruit);

		int sum = 0;
		for(int i = 0; i < K; i++) {
			sum = sum + fruit[i];
		}

		System.out.println(sum);
	}

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

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] lines = line.split(" ");
		int N = Integer.parseInt(lines[0]);
		int K = Integer.parseInt(lines[1]);

		int[] fruit = new int[N];

		line = sc.nextLine();
		lines = line.split(" ");
		for(int i = 0; i < N; i++) {
			fruit[i] = Integer.parseInt(lines[i]);
		}
		Arrays.sort(fruit);

		int sum = 0;
		for(int i = 0; i < K; i++) {
			sum = sum + fruit[i];
		}

		System.out.println(sum);
	}

} Main public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] lines = line.split(" ");
		int N = Integer.parseInt(lines[0]);
		int K = Integer.parseInt(lines[1]);

		int[] fruit = new int[N];

		line = sc.nextLine();
		lines = line.split(" ");
		for(int i = 0; i < N; i++) {
			fruit[i] = Integer.parseInt(lines[i]);
		}
		Arrays.sort(fruit);

		int sum = 0;
		for(int i = 0; i < K; i++) {
			sum = sum + fruit[i];
		}

		System.out.println(sum);
	} main {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] lines = line.split(" ");
		int N = Integer.parseInt(lines[0]);
		int K = Integer.parseInt(lines[1]);

		int[] fruit = new int[N];

		line = sc.nextLine();
		lines = line.split(" ");
		for(int i = 0; i < N; i++) {
			fruit[i] = Integer.parseInt(lines[i]);
		}
		Arrays.sort(fruit);

		int sum = 0;
		for(int i = 0; i < K; i++) {
			sum = sum + fruit[i];
		}

		System.out.println(sum);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String line = sc.nextLine(); line sc.nextLine() sc.nextLine sc String[] lines = line.split(" "); lines line.split(" ") line.split line " " int N = Integer.parseInt(lines[0]); N Integer.parseInt(lines[0]) Integer.parseInt Integer lines[0] lines 0 int K = Integer.parseInt(lines[1]); K Integer.parseInt(lines[1]) Integer.parseInt Integer lines[1] lines 1 int[] fruit = new int[N]; fruit new int[N] N line = sc.nextLine() line sc.nextLine() sc.nextLine sc lines = line.split(" ") lines line.split(" ") line.split line " " for(int i = 0; i < N; i++) {
			fruit[i] = Integer.parseInt(lines[i]);
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			fruit[i] = Integer.parseInt(lines[i]);
		} {
			fruit[i] = Integer.parseInt(lines[i]);
		} fruit[i] = Integer.parseInt(lines[i]) fruit[i] fruit i Integer.parseInt(lines[i]) Integer.parseInt Integer lines[i] lines i Arrays.sort(fruit) Arrays.sort Arrays fruit int sum = 0; sum 0 for(int i = 0; i < K; i++) {
			sum = sum + fruit[i];
		} int i = 0; int i = 0; i 0 i < K i K i++ i++ i {
			sum = sum + fruit[i];
		} {
			sum = sum + fruit[i];
		} sum = sum + fruit[i] sum sum + fruit[i] sum fruit[i] fruit 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) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] lines = line.split(" ");
		int N = Integer.parseInt(lines[0]);
		int K = Integer.parseInt(lines[1]);

		int[] fruit = new int[N];

		line = sc.nextLine();
		lines = line.split(" ");
		for(int i = 0; i < N; i++) {
			fruit[i] = Integer.parseInt(lines[i]);
		}
		Arrays.sort(fruit);

		int sum = 0;
		for(int i = 0; i < K; i++) {
			sum = sum + fruit[i];
		}

		System.out.println(sum);
	}

} public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] lines = line.split(" ");
		int N = Integer.parseInt(lines[0]);
		int K = Integer.parseInt(lines[1]);

		int[] fruit = new int[N];

		line = sc.nextLine();
		lines = line.split(" ");
		for(int i = 0; i < N; i++) {
			fruit[i] = Integer.parseInt(lines[i]);
		}
		Arrays.sort(fruit);

		int sum = 0;
		for(int i = 0; i < K; i++) {
			sum = sum + fruit[i];
		}

		System.out.println(sum);
	}

} Main

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

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] lines = line.split(" ");
		int N = Integer.parseInt(lines[0]);
		int K = Integer.parseInt(lines[1]);

		int[] fruit = new int[N];

		line = sc.nextLine();
		lines = line.split(" ");
		for(int i = 0; i < N; i++) {
			fruit[i] = Integer.parseInt(lines[i]);
		}
		Arrays.sort(fruit);

		int sum = 0;
		for(int i = 0; i < K; i++) {
			sum = sum + fruit[i];
		}

		System.out.println(sum);
	}

}
