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

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

  		
      	int n = sc.nextInt();
      	int k = sc.nextInt();
      	int frs[] = new int[n];
      	int prs = 0;
      	
      	for(int i = 0;i < n;i++) frs[i] = sc.nextInt();
      	Arrays.sort(frs);
      	for(int i = 0;i < k;i++) prs += frs[i];
      
      	System.out.println(prs);
        
	}
} import java.util.*; util.* java import java.lang.Math; Math java.lang public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

  		
      	int n = sc.nextInt();
      	int k = sc.nextInt();
      	int frs[] = new int[n];
      	int prs = 0;
      	
      	for(int i = 0;i < n;i++) frs[i] = sc.nextInt();
      	Arrays.sort(frs);
      	for(int i = 0;i < k;i++) prs += frs[i];
      
      	System.out.println(prs);
        
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

  		
      	int n = sc.nextInt();
      	int k = sc.nextInt();
      	int frs[] = new int[n];
      	int prs = 0;
      	
      	for(int i = 0;i < n;i++) frs[i] = sc.nextInt();
      	Arrays.sort(frs);
      	for(int i = 0;i < k;i++) prs += frs[i];
      
      	System.out.println(prs);
        
	} main {
		Scanner sc = new Scanner(System.in);

  		
      	int n = sc.nextInt();
      	int k = sc.nextInt();
      	int frs[] = new int[n];
      	int prs = 0;
      	
      	for(int i = 0;i < n;i++) frs[i] = sc.nextInt();
      	Arrays.sort(frs);
      	for(int i = 0;i < k;i++) prs += frs[i];
      
      	System.out.println(prs);
        
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int k = sc.nextInt(); k sc.nextInt() sc.nextInt sc int frs[] = new int[n]; frs new int[n] n int prs = 0; prs 0 for(int i = 0;i < n;i++) frs[i] = sc.nextInt(); int i = 0; int i = 0; i 0 i < n i n i++ i++ i frs[i] = sc.nextInt(); frs[i] = sc.nextInt() frs[i] frs i sc.nextInt() sc.nextInt sc Arrays.sort(frs) Arrays.sort Arrays frs for(int i = 0;i < k;i++) prs += frs[i]; int i = 0; int i = 0; i 0 i < k i k i++ i++ i prs += frs[i]; prs += frs[i] prs frs[i] frs i System.out.println(prs) System.out.println System.out System System.out prs String[] args args public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

  		
      	int n = sc.nextInt();
      	int k = sc.nextInt();
      	int frs[] = new int[n];
      	int prs = 0;
      	
      	for(int i = 0;i < n;i++) frs[i] = sc.nextInt();
      	Arrays.sort(frs);
      	for(int i = 0;i < k;i++) prs += frs[i];
      
      	System.out.println(prs);
        
	}
} public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

  		
      	int n = sc.nextInt();
      	int k = sc.nextInt();
      	int frs[] = new int[n];
      	int prs = 0;
      	
      	for(int i = 0;i < n;i++) frs[i] = sc.nextInt();
      	Arrays.sort(frs);
      	for(int i = 0;i < k;i++) prs += frs[i];
      
      	System.out.println(prs);
        
	}
} Main
import java.util.*;
import java.lang.Math;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

  		
      	int n = sc.nextInt();
      	int k = sc.nextInt();
      	int frs[] = new int[n];
      	int prs = 0;
      	
      	for(int i = 0;i < n;i++) frs[i] = sc.nextInt();
      	Arrays.sort(frs);
      	for(int i = 0;i < k;i++) prs += frs[i];
      
      	System.out.println(prs);
        
	}
}
