import java.util.*; 
import java.lang.*; 


public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
                
                int N = scan.nextInt();
                int K = scan.nextInt();
                
                int[] ans = new int[N];
                
                for(int i=0; i<N; i++){
                    ans[i]  = scan.nextInt();
                }
                Arrays.sort(ans);
                
                int answer = 0;
                for(int i=0; i<K; i++){
                    answer = answer + ans[i];
                }
                
                System.out.println(answer);
        }
                
} import java.util.*; util.* java import java.lang.*; lang.* java public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
                
                int N = scan.nextInt();
                int K = scan.nextInt();
                
                int[] ans = new int[N];
                
                for(int i=0; i<N; i++){
                    ans[i]  = scan.nextInt();
                }
                Arrays.sort(ans);
                
                int answer = 0;
                for(int i=0; i<K; i++){
                    answer = answer + ans[i];
                }
                
                System.out.println(answer);
        }
                
} Main public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
                
                int N = scan.nextInt();
                int K = scan.nextInt();
                
                int[] ans = new int[N];
                
                for(int i=0; i<N; i++){
                    ans[i]  = scan.nextInt();
                }
                Arrays.sort(ans);
                
                int answer = 0;
                for(int i=0; i<K; i++){
                    answer = answer + ans[i];
                }
                
                System.out.println(answer);
        } main {
		Scanner scan = new Scanner(System.in);
                
                int N = scan.nextInt();
                int K = scan.nextInt();
                
                int[] ans = new int[N];
                
                for(int i=0; i<N; i++){
                    ans[i]  = scan.nextInt();
                }
                Arrays.sort(ans);
                
                int answer = 0;
                for(int i=0; i<K; i++){
                    answer = answer + ans[i];
                }
                
                System.out.println(answer);
        } 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[] ans = new int[N]; ans new int[N] N for(int i=0; i<N; i++){
                    ans[i]  = scan.nextInt();
                } int i=0; int i=0; i 0 i<N i N i++ i++ i {
                    ans[i]  = scan.nextInt();
                } {
                    ans[i]  = scan.nextInt();
                } ans[i]  = scan.nextInt() ans[i] ans i scan.nextInt() scan.nextInt scan Arrays.sort(ans) Arrays.sort Arrays ans int answer = 0; answer 0 for(int i=0; i<K; i++){
                    answer = answer + ans[i];
                } int i=0; int i=0; i 0 i<K i K i++ i++ i {
                    answer = answer + ans[i];
                } {
                    answer = answer + ans[i];
                } answer = answer + ans[i] answer answer + ans[i] answer ans[i] ans 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){
		Scanner scan = new Scanner(System.in);
                
                int N = scan.nextInt();
                int K = scan.nextInt();
                
                int[] ans = new int[N];
                
                for(int i=0; i<N; i++){
                    ans[i]  = scan.nextInt();
                }
                Arrays.sort(ans);
                
                int answer = 0;
                for(int i=0; i<K; i++){
                    answer = answer + ans[i];
                }
                
                System.out.println(answer);
        }
                
} public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
                
                int N = scan.nextInt();
                int K = scan.nextInt();
                
                int[] ans = new int[N];
                
                for(int i=0; i<N; i++){
                    ans[i]  = scan.nextInt();
                }
                Arrays.sort(ans);
                
                int answer = 0;
                for(int i=0; i<K; i++){
                    answer = answer + ans[i];
                }
                
                System.out.println(answer);
        }
                
} Main
import java.util.*; 
import java.lang.*; 


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