import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        String[] strNum = br.readLine().split(" ");
        String[] strPrice = br.readLine().split(" ");
        int n = Integer.parseInt(strNum[0]);
        int k = Integer.parseInt(strNum[1]);
        Integer[] price = new Integer[n];
        
        for(int i = 0; i < price.length; i++){
            price[i] = Integer.valueOf(strPrice[i]);
        }
        
        Arrays.sort(price);
        
        int sum = 0;
        
        for(int i = 0; i < k; i++){
            sum += price[i];
        }
        
        out.println(sum);
        
        out.flush();
        out.close();
        
    }
} import java.util.*; util.* java import java.io.*; io.* java public class Main {
    public static void main(String[] args) throws Exception {
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        String[] strNum = br.readLine().split(" ");
        String[] strPrice = br.readLine().split(" ");
        int n = Integer.parseInt(strNum[0]);
        int k = Integer.parseInt(strNum[1]);
        Integer[] price = new Integer[n];
        
        for(int i = 0; i < price.length; i++){
            price[i] = Integer.valueOf(strPrice[i]);
        }
        
        Arrays.sort(price);
        
        int sum = 0;
        
        for(int i = 0; i < k; i++){
            sum += price[i];
        }
        
        out.println(sum);
        
        out.flush();
        out.close();
        
    }
} Main public static void main(String[] args) throws Exception {
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        String[] strNum = br.readLine().split(" ");
        String[] strPrice = br.readLine().split(" ");
        int n = Integer.parseInt(strNum[0]);
        int k = Integer.parseInt(strNum[1]);
        Integer[] price = new Integer[n];
        
        for(int i = 0; i < price.length; i++){
            price[i] = Integer.valueOf(strPrice[i]);
        }
        
        Arrays.sort(price);
        
        int sum = 0;
        
        for(int i = 0; i < k; i++){
            sum += price[i];
        }
        
        out.println(sum);
        
        out.flush();
        out.close();
        
    } main {
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        String[] strNum = br.readLine().split(" ");
        String[] strPrice = br.readLine().split(" ");
        int n = Integer.parseInt(strNum[0]);
        int k = Integer.parseInt(strNum[1]);
        Integer[] price = new Integer[n];
        
        for(int i = 0; i < price.length; i++){
            price[i] = Integer.valueOf(strPrice[i]);
        }
        
        Arrays.sort(price);
        
        int sum = 0;
        
        for(int i = 0; i < k; i++){
            sum += price[i];
        }
        
        out.println(sum);
        
        out.flush();
        out.close();
        
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); out new PrintWriter(new OutputStreamWriter(System.out)) String[] strNum = br.readLine().split(" "); strNum br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " String[] strPrice = br.readLine().split(" "); strPrice br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int n = Integer.parseInt(strNum[0]); n Integer.parseInt(strNum[0]) Integer.parseInt Integer strNum[0] strNum 0 int k = Integer.parseInt(strNum[1]); k Integer.parseInt(strNum[1]) Integer.parseInt Integer strNum[1] strNum 1 Integer[] price = new Integer[n]; price new Integer[n] n for(int i = 0; i < price.length; i++){
            price[i] = Integer.valueOf(strPrice[i]);
        } int i = 0; int i = 0; i 0 i < price.length i price.length price price.length i++ i++ i {
            price[i] = Integer.valueOf(strPrice[i]);
        } {
            price[i] = Integer.valueOf(strPrice[i]);
        } price[i] = Integer.valueOf(strPrice[i]) price[i] price i Integer.valueOf(strPrice[i]) Integer.valueOf Integer strPrice[i] strPrice i 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 out.println(sum) out.println out sum out.flush() out.flush out out.close() out.close out String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        String[] strNum = br.readLine().split(" ");
        String[] strPrice = br.readLine().split(" ");
        int n = Integer.parseInt(strNum[0]);
        int k = Integer.parseInt(strNum[1]);
        Integer[] price = new Integer[n];
        
        for(int i = 0; i < price.length; i++){
            price[i] = Integer.valueOf(strPrice[i]);
        }
        
        Arrays.sort(price);
        
        int sum = 0;
        
        for(int i = 0; i < k; i++){
            sum += price[i];
        }
        
        out.println(sum);
        
        out.flush();
        out.close();
        
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        String[] strNum = br.readLine().split(" ");
        String[] strPrice = br.readLine().split(" ");
        int n = Integer.parseInt(strNum[0]);
        int k = Integer.parseInt(strNum[1]);
        Integer[] price = new Integer[n];
        
        for(int i = 0; i < price.length; i++){
            price[i] = Integer.valueOf(strPrice[i]);
        }
        
        Arrays.sort(price);
        
        int sum = 0;
        
        for(int i = 0; i < k; i++){
            sum += price[i];
        }
        
        out.println(sum);
        
        out.flush();
        out.close();
        
    }
} Main
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        String[] strNum = br.readLine().split(" ");
        String[] strPrice = br.readLine().split(" ");
        int n = Integer.parseInt(strNum[0]);
        int k = Integer.parseInt(strNum[1]);
        Integer[] price = new Integer[n];
        
        for(int i = 0; i < price.length; i++){
            price[i] = Integer.valueOf(strPrice[i]);
        }
        
        Arrays.sort(price);
        
        int sum = 0;
        
        for(int i = 0; i < k; i++){
            sum += price[i];
        }
        
        out.println(sum);
        
        out.flush();
        out.close();
        
    }
}