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

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();
		
		int[] list = new int[n];
		for(int i = 0; i < n; i++) {
			list[i] = scan.nextInt();
		}
		
		Arrays.sort(list);
		int total = 0;
		for(int i = 0; i<k; i++) {
			total += list[i];
		}
		System.out.print(total);
	}

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

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();
		
		int[] list = new int[n];
		for(int i = 0; i < n; i++) {
			list[i] = scan.nextInt();
		}
		
		Arrays.sort(list);
		int total = 0;
		for(int i = 0; i<k; i++) {
			total += list[i];
		}
		System.out.print(total);
	}

} Main public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();
		
		int[] list = new int[n];
		for(int i = 0; i < n; i++) {
			list[i] = scan.nextInt();
		}
		
		Arrays.sort(list);
		int total = 0;
		for(int i = 0; i<k; i++) {
			total += list[i];
		}
		System.out.print(total);
	} main {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();
		
		int[] list = new int[n];
		for(int i = 0; i < n; i++) {
			list[i] = scan.nextInt();
		}
		
		Arrays.sort(list);
		int total = 0;
		for(int i = 0; i<k; i++) {
			total += list[i];
		}
		System.out.print(total);
	} 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 int[] list = new int[n]; list new int[n] n for(int i = 0; i < n; i++) {
			list[i] = scan.nextInt();
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			list[i] = scan.nextInt();
		} {
			list[i] = scan.nextInt();
		} list[i] = scan.nextInt() list[i] list i scan.nextInt() scan.nextInt scan Arrays.sort(list) Arrays.sort Arrays list int total = 0; total 0 for(int i = 0; i<k; i++) {
			total += list[i];
		} int i = 0; int i = 0; i 0 i<k i k i++ i++ i {
			total += list[i];
		} {
			total += list[i];
		} total += list[i] total list[i] list i System.out.print(total) System.out.print System.out System System.out total String[] args args public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();
		
		int[] list = new int[n];
		for(int i = 0; i < n; i++) {
			list[i] = scan.nextInt();
		}
		
		Arrays.sort(list);
		int total = 0;
		for(int i = 0; i<k; i++) {
			total += list[i];
		}
		System.out.print(total);
	}

} public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();
		
		int[] list = new int[n];
		for(int i = 0; i < n; i++) {
			list[i] = scan.nextInt();
		}
		
		Arrays.sort(list);
		int total = 0;
		for(int i = 0; i<k; i++) {
			total += list[i];
		}
		System.out.print(total);
	}

} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();
		
		int[] list = new int[n];
		for(int i = 0; i < n; i++) {
			list[i] = scan.nextInt();
		}
		
		Arrays.sort(list);
		int total = 0;
		for(int i = 0; i<k; i++) {
			total += list[i];
		}
		System.out.print(total);
	}

}
