import java.util.*;
import java.io.*;
import java.math.BigDecimal;
import java.nio.file.Files;
import java.nio.charset.StandardCharsets;
//给出两个数a,b 求出[a,b]中各位数字之和能整除原数的数的个数。
public class Main {

    int mod ;
    //
    int[][] dp = new int[1001][1001];
    void solve(int n, int k , int[] arr) {
        Arrays.sort(arr);
        int res = 0;
        for(int i=0;i<k;i++){
            res+=arr[i];
        }
        System.out.println(res);
    }


    public static void main(String[] args)  throws IOException {
        // Use the Scanner class

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[]  s = br.readLine().split(" ");
        Main test = new Main();

        int n = Integer.parseInt(s[0]);
        int k = Integer.parseInt(s[1]);
        int[] arr = new int[n];
        int i=0;
        s = br.readLine().split(" ");
        while(i<n){
            arr[i] = Integer.parseInt(s[i]);
            i++;
        }
        test.solve(n,k,arr);
        //int tot = Integer.parseInt(br.readLine());


//        int i =1;
//        System.out.println();
//        while(tot>0){
//
//            String s = br.readLine();
//            String[] sr = s.split(" ");
//            List<Long> ls = new ArrayList<>();
//            for(String ss:sr){
//                ls.add(Long.parseLong(ss));
//            }
//            Main tt = new Main();
//            tt.sol(ls);
//            // String Buffer to store answer
//            StringBuffer sb = new StringBuffer();
////            Solution obj = new Solution();
////
////            System.out.println("Case #"+i+": "+obj.sol());
//            tot--;
//            i++;
//        }
    }

} import java.util.*; util.* java import java.io.*; io.* java import java.math.BigDecimal; BigDecimal java.math import java.nio.file.Files; Files java.nio.file import java.nio.charset.StandardCharsets; StandardCharsets java.nio.charset public class Main {

    int mod ;
    //
    int[][] dp = new int[1001][1001];
    void solve(int n, int k , int[] arr) {
        Arrays.sort(arr);
        int res = 0;
        for(int i=0;i<k;i++){
            res+=arr[i];
        }
        System.out.println(res);
    }


    public static void main(String[] args)  throws IOException {
        // Use the Scanner class

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[]  s = br.readLine().split(" ");
        Main test = new Main();

        int n = Integer.parseInt(s[0]);
        int k = Integer.parseInt(s[1]);
        int[] arr = new int[n];
        int i=0;
        s = br.readLine().split(" ");
        while(i<n){
            arr[i] = Integer.parseInt(s[i]);
            i++;
        }
        test.solve(n,k,arr);
        //int tot = Integer.parseInt(br.readLine());


//        int i =1;
//        System.out.println();
//        while(tot>0){
//
//            String s = br.readLine();
//            String[] sr = s.split(" ");
//            List<Long> ls = new ArrayList<>();
//            for(String ss:sr){
//                ls.add(Long.parseLong(ss));
//            }
//            Main tt = new Main();
//            tt.sol(ls);
//            // String Buffer to store answer
//            StringBuffer sb = new StringBuffer();
////            Solution obj = new Solution();
////
////            System.out.println("Case #"+i+": "+obj.sol());
//            tot--;
//            i++;
//        }
    }

} Main int mod ; mod //
    int[][] dp = new int[1001][1001]; dp new int[1001][1001] 1001 1001 void solve(int n, int k , int[] arr) {
        Arrays.sort(arr);
        int res = 0;
        for(int i=0;i<k;i++){
            res+=arr[i];
        }
        System.out.println(res);
    } solve {
        Arrays.sort(arr);
        int res = 0;
        for(int i=0;i<k;i++){
            res+=arr[i];
        }
        System.out.println(res);
    } Arrays.sort(arr) Arrays.sort Arrays arr int res = 0; res 0 for(int i=0;i<k;i++){
            res+=arr[i];
        } int i=0; int i=0; i 0 i<k i k i++ i++ i {
            res+=arr[i];
        } {
            res+=arr[i];
        } res+=arr[i] res arr[i] arr i System.out.println(res) System.out.println System.out System System.out res int n n int k k int[] arr arr public static void main(String[] args)  throws IOException {
        // Use the Scanner class

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[]  s = br.readLine().split(" ");
        Main test = new Main();

        int n = Integer.parseInt(s[0]);
        int k = Integer.parseInt(s[1]);
        int[] arr = new int[n];
        int i=0;
        s = br.readLine().split(" ");
        while(i<n){
            arr[i] = Integer.parseInt(s[i]);
            i++;
        }
        test.solve(n,k,arr);
        //int tot = Integer.parseInt(br.readLine());


//        int i =1;
//        System.out.println();
//        while(tot>0){
//
//            String s = br.readLine();
//            String[] sr = s.split(" ");
//            List<Long> ls = new ArrayList<>();
//            for(String ss:sr){
//                ls.add(Long.parseLong(ss));
//            }
//            Main tt = new Main();
//            tt.sol(ls);
//            // String Buffer to store answer
//            StringBuffer sb = new StringBuffer();
////            Solution obj = new Solution();
////
////            System.out.println("Case #"+i+": "+obj.sol());
//            tot--;
//            i++;
//        }
    } main {
        // Use the Scanner class

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[]  s = br.readLine().split(" ");
        Main test = new Main();

        int n = Integer.parseInt(s[0]);
        int k = Integer.parseInt(s[1]);
        int[] arr = new int[n];
        int i=0;
        s = br.readLine().split(" ");
        while(i<n){
            arr[i] = Integer.parseInt(s[i]);
            i++;
        }
        test.solve(n,k,arr);
        //int tot = Integer.parseInt(br.readLine());


//        int i =1;
//        System.out.println();
//        while(tot>0){
//
//            String s = br.readLine();
//            String[] sr = s.split(" ");
//            List<Long> ls = new ArrayList<>();
//            for(String ss:sr){
//                ls.add(Long.parseLong(ss));
//            }
//            Main tt = new Main();
//            tt.sol(ls);
//            // String Buffer to store answer
//            StringBuffer sb = new StringBuffer();
////            Solution obj = new Solution();
////
////            System.out.println("Case #"+i+": "+obj.sol());
//            tot--;
//            i++;
//        }
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[]  s = br.readLine().split(" "); s br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " Main test = new Main(); test new Main() int n = Integer.parseInt(s[0]); n Integer.parseInt(s[0]) Integer.parseInt Integer s[0] s 0 int k = Integer.parseInt(s[1]); k Integer.parseInt(s[1]) Integer.parseInt Integer s[1] s 1 int[] arr = new int[n]; arr new int[n] n int i=0; i 0 s = br.readLine().split(" ") s br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " while(i<n){
            arr[i] = Integer.parseInt(s[i]);
            i++;
        } i<n i n {
            arr[i] = Integer.parseInt(s[i]);
            i++;
        } arr[i] = Integer.parseInt(s[i]) arr[i] arr i Integer.parseInt(s[i]) Integer.parseInt Integer s[i] s i i++ i test.solve(n,k,arr) test.solve test n k arr String[] args args public class Main {

    int mod ;
    //
    int[][] dp = new int[1001][1001];
    void solve(int n, int k , int[] arr) {
        Arrays.sort(arr);
        int res = 0;
        for(int i=0;i<k;i++){
            res+=arr[i];
        }
        System.out.println(res);
    }


    public static void main(String[] args)  throws IOException {
        // Use the Scanner class

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[]  s = br.readLine().split(" ");
        Main test = new Main();

        int n = Integer.parseInt(s[0]);
        int k = Integer.parseInt(s[1]);
        int[] arr = new int[n];
        int i=0;
        s = br.readLine().split(" ");
        while(i<n){
            arr[i] = Integer.parseInt(s[i]);
            i++;
        }
        test.solve(n,k,arr);
        //int tot = Integer.parseInt(br.readLine());


//        int i =1;
//        System.out.println();
//        while(tot>0){
//
//            String s = br.readLine();
//            String[] sr = s.split(" ");
//            List<Long> ls = new ArrayList<>();
//            for(String ss:sr){
//                ls.add(Long.parseLong(ss));
//            }
//            Main tt = new Main();
//            tt.sol(ls);
//            // String Buffer to store answer
//            StringBuffer sb = new StringBuffer();
////            Solution obj = new Solution();
////
////            System.out.println("Case #"+i+": "+obj.sol());
//            tot--;
//            i++;
//        }
    }

} public class Main {

    int mod ;
    //
    int[][] dp = new int[1001][1001];
    void solve(int n, int k , int[] arr) {
        Arrays.sort(arr);
        int res = 0;
        for(int i=0;i<k;i++){
            res+=arr[i];
        }
        System.out.println(res);
    }


    public static void main(String[] args)  throws IOException {
        // Use the Scanner class

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[]  s = br.readLine().split(" ");
        Main test = new Main();

        int n = Integer.parseInt(s[0]);
        int k = Integer.parseInt(s[1]);
        int[] arr = new int[n];
        int i=0;
        s = br.readLine().split(" ");
        while(i<n){
            arr[i] = Integer.parseInt(s[i]);
            i++;
        }
        test.solve(n,k,arr);
        //int tot = Integer.parseInt(br.readLine());


//        int i =1;
//        System.out.println();
//        while(tot>0){
//
//            String s = br.readLine();
//            String[] sr = s.split(" ");
//            List<Long> ls = new ArrayList<>();
//            for(String ss:sr){
//                ls.add(Long.parseLong(ss));
//            }
//            Main tt = new Main();
//            tt.sol(ls);
//            // String Buffer to store answer
//            StringBuffer sb = new StringBuffer();
////            Solution obj = new Solution();
////
////            System.out.println("Case #"+i+": "+obj.sol());
//            tot--;
//            i++;
//        }
    }

} Main
import java.util.*;
import java.io.*;
import java.math.BigDecimal;
import java.nio.file.Files;
import java.nio.charset.StandardCharsets;
//给出两个数a,b 求出[a,b]中各位数字之和能整除原数的数的个数。
public class Main {

    int mod ;
    //
    int[][] dp = new int[1001][1001];
    void solve(int n, int k , int[] arr) {
        Arrays.sort(arr);
        int res = 0;
        for(int i=0;i<k;i++){
            res+=arr[i];
        }
        System.out.println(res);
    }


    public static void main(String[] args)  throws IOException {
        // Use the Scanner class

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[]  s = br.readLine().split(" ");
        Main test = new Main();

        int n = Integer.parseInt(s[0]);
        int k = Integer.parseInt(s[1]);
        int[] arr = new int[n];
        int i=0;
        s = br.readLine().split(" ");
        while(i<n){
            arr[i] = Integer.parseInt(s[i]);
            i++;
        }
        test.solve(n,k,arr);
        //int tot = Integer.parseInt(br.readLine());


//        int i =1;
//        System.out.println();
//        while(tot>0){
//
//            String s = br.readLine();
//            String[] sr = s.split(" ");
//            List<Long> ls = new ArrayList<>();
//            for(String ss:sr){
//                ls.add(Long.parseLong(ss));
//            }
//            Main tt = new Main();
//            tt.sol(ls);
//            // String Buffer to store answer
//            StringBuffer sb = new StringBuffer();
////            Solution obj = new Solution();
////
////            System.out.println("Case #"+i+": "+obj.sol());
//            tot--;
//            i++;
//        }
    }

}
