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

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int length = scanner.nextInt();
		int chosen = scanner.nextInt();
		int[] numbers = new int[length];
		for(int i = 0; i < length; i++) 
			numbers[i] = scanner.nextInt();
		
		Arrays.sort(numbers);
		
		long result = 0l;
		for(int i = 0; i < chosen; i++) 
			result += numbers[i];
		System.out.print(result);
	}
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int length = scanner.nextInt();
		int chosen = scanner.nextInt();
		int[] numbers = new int[length];
		for(int i = 0; i < length; i++) 
			numbers[i] = scanner.nextInt();
		
		Arrays.sort(numbers);
		
		long result = 0l;
		for(int i = 0; i < chosen; i++) 
			result += numbers[i];
		System.out.print(result);
	}
} Main public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int length = scanner.nextInt();
		int chosen = scanner.nextInt();
		int[] numbers = new int[length];
		for(int i = 0; i < length; i++) 
			numbers[i] = scanner.nextInt();
		
		Arrays.sort(numbers);
		
		long result = 0l;
		for(int i = 0; i < chosen; i++) 
			result += numbers[i];
		System.out.print(result);
	} main {
		Scanner scanner = new Scanner(System.in);
		int length = scanner.nextInt();
		int chosen = scanner.nextInt();
		int[] numbers = new int[length];
		for(int i = 0; i < length; i++) 
			numbers[i] = scanner.nextInt();
		
		Arrays.sort(numbers);
		
		long result = 0l;
		for(int i = 0; i < chosen; i++) 
			result += numbers[i];
		System.out.print(result);
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int length = scanner.nextInt(); length scanner.nextInt() scanner.nextInt scanner int chosen = scanner.nextInt(); chosen scanner.nextInt() scanner.nextInt scanner int[] numbers = new int[length]; numbers new int[length] length for(int i = 0; i < length; i++) 
			numbers[i] = scanner.nextInt(); int i = 0; int i = 0; i 0 i < length i length i++ i++ i numbers[i] = scanner.nextInt(); numbers[i] = scanner.nextInt() numbers[i] numbers i scanner.nextInt() scanner.nextInt scanner Arrays.sort(numbers) Arrays.sort Arrays numbers long result = 0l; result 0l for(int i = 0; i < chosen; i++) 
			result += numbers[i]; int i = 0; int i = 0; i 0 i < chosen i chosen i++ i++ i result += numbers[i]; result += numbers[i] result numbers[i] numbers i System.out.print(result) System.out.print System.out System System.out result String[] args args public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int length = scanner.nextInt();
		int chosen = scanner.nextInt();
		int[] numbers = new int[length];
		for(int i = 0; i < length; i++) 
			numbers[i] = scanner.nextInt();
		
		Arrays.sort(numbers);
		
		long result = 0l;
		for(int i = 0; i < chosen; i++) 
			result += numbers[i];
		System.out.print(result);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int length = scanner.nextInt();
		int chosen = scanner.nextInt();
		int[] numbers = new int[length];
		for(int i = 0; i < length; i++) 
			numbers[i] = scanner.nextInt();
		
		Arrays.sort(numbers);
		
		long result = 0l;
		for(int i = 0; i < chosen; i++) 
			result += numbers[i];
		System.out.print(result);
	}
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int length = scanner.nextInt();
		int chosen = scanner.nextInt();
		int[] numbers = new int[length];
		for(int i = 0; i < length; i++) 
			numbers[i] = scanner.nextInt();
		
		Arrays.sort(numbers);
		
		long result = 0l;
		for(int i = 0; i < chosen; i++) 
			result += numbers[i];
		System.out.print(result);
	}
}
