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

public class Main {
	public static void main(String[] args){
      	Scanner scan = new Scanner(System.in);
		int zentai = scan.nextInt();
 		int kounyu = scan.nextInt();
        int[] priceArray = new int[zentai];
      int ans = 0;

		for(int i=0; i<zentai; i++){
			priceArray[i] = scan.nextInt();
			}
        Arrays.sort(priceArray);
      	for(int i=0; i<kounyu; i++){
			ans += priceArray[i];
			}

		System.out.println(ans);   
 
	}
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args){
      	Scanner scan = new Scanner(System.in);
		int zentai = scan.nextInt();
 		int kounyu = scan.nextInt();
        int[] priceArray = new int[zentai];
      int ans = 0;

		for(int i=0; i<zentai; i++){
			priceArray[i] = scan.nextInt();
			}
        Arrays.sort(priceArray);
      	for(int i=0; i<kounyu; i++){
			ans += priceArray[i];
			}

		System.out.println(ans);   
 
	}
} Main public static void main(String[] args){
      	Scanner scan = new Scanner(System.in);
		int zentai = scan.nextInt();
 		int kounyu = scan.nextInt();
        int[] priceArray = new int[zentai];
      int ans = 0;

		for(int i=0; i<zentai; i++){
			priceArray[i] = scan.nextInt();
			}
        Arrays.sort(priceArray);
      	for(int i=0; i<kounyu; i++){
			ans += priceArray[i];
			}

		System.out.println(ans);   
 
	} main {
      	Scanner scan = new Scanner(System.in);
		int zentai = scan.nextInt();
 		int kounyu = scan.nextInt();
        int[] priceArray = new int[zentai];
      int ans = 0;

		for(int i=0; i<zentai; i++){
			priceArray[i] = scan.nextInt();
			}
        Arrays.sort(priceArray);
      	for(int i=0; i<kounyu; i++){
			ans += priceArray[i];
			}

		System.out.println(ans);   
 
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int zentai = scan.nextInt(); zentai scan.nextInt() scan.nextInt scan int kounyu = scan.nextInt(); kounyu scan.nextInt() scan.nextInt scan int[] priceArray = new int[zentai]; priceArray new int[zentai] zentai int ans = 0; ans 0 for(int i=0; i<zentai; i++){
			priceArray[i] = scan.nextInt();
			} int i=0; int i=0; i 0 i<zentai i zentai i++ i++ i {
			priceArray[i] = scan.nextInt();
			} {
			priceArray[i] = scan.nextInt();
			} priceArray[i] = scan.nextInt() priceArray[i] priceArray i scan.nextInt() scan.nextInt scan Arrays.sort(priceArray) Arrays.sort Arrays priceArray for(int i=0; i<kounyu; i++){
			ans += priceArray[i];
			} int i=0; int i=0; i 0 i<kounyu i kounyu i++ i++ i {
			ans += priceArray[i];
			} {
			ans += priceArray[i];
			} ans += priceArray[i] ans priceArray[i] priceArray i System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
	public static void main(String[] args){
      	Scanner scan = new Scanner(System.in);
		int zentai = scan.nextInt();
 		int kounyu = scan.nextInt();
        int[] priceArray = new int[zentai];
      int ans = 0;

		for(int i=0; i<zentai; i++){
			priceArray[i] = scan.nextInt();
			}
        Arrays.sort(priceArray);
      	for(int i=0; i<kounyu; i++){
			ans += priceArray[i];
			}

		System.out.println(ans);   
 
	}
} public class Main {
	public static void main(String[] args){
      	Scanner scan = new Scanner(System.in);
		int zentai = scan.nextInt();
 		int kounyu = scan.nextInt();
        int[] priceArray = new int[zentai];
      int ans = 0;

		for(int i=0; i<zentai; i++){
			priceArray[i] = scan.nextInt();
			}
        Arrays.sort(priceArray);
      	for(int i=0; i<kounyu; i++){
			ans += priceArray[i];
			}

		System.out.println(ans);   
 
	}
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
      	Scanner scan = new Scanner(System.in);
		int zentai = scan.nextInt();
 		int kounyu = scan.nextInt();
        int[] priceArray = new int[zentai];
      int ans = 0;

		for(int i=0; i<zentai; i++){
			priceArray[i] = scan.nextInt();
			}
        Arrays.sort(priceArray);
      	for(int i=0; i<kounyu; i++){
			ans += priceArray[i];
			}

		System.out.println(ans);   
 
	}
}