import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;

public class Main {


    public static void main(String[] args) throws IOException {
    
    	Scanner scan = new Scanner(System.in);

    	
    	int n = scan.nextInt(); int k = scan.nextInt();
    	
    	int [] price = new int[n];
    	
    	for(int i=0; i<n; i++) {
    		int line = scan.nextInt();
    		price[i] = line;
    	}
    	
    	Arrays.sort(price);
    	int sum = 0;
    	
    	for(int i=0; i<k; i++) {
    		sum+= price[i];
    	}
    	
    	System.out.println(sum);
    	
    } 	
} import java.io.*; io.* java import java.math.*; math.* java import java.security.*; security.* java import java.text.*; text.* java import java.util.*; util.* java import java.util.concurrent.*; concurrent.* java.util import java.util.regex.*; regex.* java.util public class Main {


    public static void main(String[] args) throws IOException {
    
    	Scanner scan = new Scanner(System.in);

    	
    	int n = scan.nextInt(); int k = scan.nextInt();
    	
    	int [] price = new int[n];
    	
    	for(int i=0; i<n; i++) {
    		int line = scan.nextInt();
    		price[i] = line;
    	}
    	
    	Arrays.sort(price);
    	int sum = 0;
    	
    	for(int i=0; i<k; i++) {
    		sum+= price[i];
    	}
    	
    	System.out.println(sum);
    	
    } 	
} Main public static void main(String[] args) throws IOException {
    
    	Scanner scan = new Scanner(System.in);

    	
    	int n = scan.nextInt(); int k = scan.nextInt();
    	
    	int [] price = new int[n];
    	
    	for(int i=0; i<n; i++) {
    		int line = scan.nextInt();
    		price[i] = line;
    	}
    	
    	Arrays.sort(price);
    	int sum = 0;
    	
    	for(int i=0; i<k; i++) {
    		sum+= price[i];
    	}
    	
    	System.out.println(sum);
    	
    } main {
    
    	Scanner scan = new Scanner(System.in);

    	
    	int n = scan.nextInt(); int k = scan.nextInt();
    	
    	int [] price = new int[n];
    	
    	for(int i=0; i<n; i++) {
    		int line = scan.nextInt();
    		price[i] = line;
    	}
    	
    	Arrays.sort(price);
    	int sum = 0;
    	
    	for(int i=0; i<k; i++) {
    		sum+= price[i];
    	}
    	
    	System.out.println(sum);
    	
    } 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 [] price = new int[n]; price new int[n] n for(int i=0; i<n; i++) {
    		int line = scan.nextInt();
    		price[i] = line;
    	} int i=0; int i=0; i 0 i<n i n i++ i++ i {
    		int line = scan.nextInt();
    		price[i] = line;
    	} {
    		int line = scan.nextInt();
    		price[i] = line;
    	} int line = scan.nextInt(); line scan.nextInt() scan.nextInt scan price[i] = line price[i] price i line Arrays.sort(price) Arrays.sort Arrays price int sum = 0; sum 0 for(int i=0; i<k; i++) {
    		sum+= price[i];
    	} int i=0; int i=0; i 0 i<k i k i++ i++ i {
    		sum+= price[i];
    	} {
    		sum+= price[i];
    	} sum+= price[i] sum price[i] price i System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {


    public static void main(String[] args) throws IOException {
    
    	Scanner scan = new Scanner(System.in);

    	
    	int n = scan.nextInt(); int k = scan.nextInt();
    	
    	int [] price = new int[n];
    	
    	for(int i=0; i<n; i++) {
    		int line = scan.nextInt();
    		price[i] = line;
    	}
    	
    	Arrays.sort(price);
    	int sum = 0;
    	
    	for(int i=0; i<k; i++) {
    		sum+= price[i];
    	}
    	
    	System.out.println(sum);
    	
    } 	
} public class Main {


    public static void main(String[] args) throws IOException {
    
    	Scanner scan = new Scanner(System.in);

    	
    	int n = scan.nextInt(); int k = scan.nextInt();
    	
    	int [] price = new int[n];
    	
    	for(int i=0; i<n; i++) {
    		int line = scan.nextInt();
    		price[i] = line;
    	}
    	
    	Arrays.sort(price);
    	int sum = 0;
    	
    	for(int i=0; i<k; i++) {
    		sum+= price[i];
    	}
    	
    	System.out.println(sum);
    	
    } 	
} Main
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;

public class Main {


    public static void main(String[] args) throws IOException {
    
    	Scanner scan = new Scanner(System.in);

    	
    	int n = scan.nextInt(); int k = scan.nextInt();
    	
    	int [] price = new int[n];
    	
    	for(int i=0; i<n; i++) {
    		int line = scan.nextInt();
    		price[i] = line;
    	}
    	
    	Arrays.sort(price);
    	int sum = 0;
    	
    	for(int i=0; i<k; i++) {
    		sum+= price[i];
    	}
    	
    	System.out.println(sum);
    	
    } 	
}
