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

public class Main {
    public static void main(String[] args) throws Exception {
        try{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            
            String strSplit[] = br.readLine().split(" ");
            int N = Integer.parseInt(strSplit[0]);
            int K = Integer.parseInt(strSplit[1]);
            
            String strSplitFruitsPrice[] = br.readLine().split(" ");
            int fruitsPrice[] = new int[N];
            for(int i=0; i<N; i++){
                fruitsPrice[i] = Integer.parseInt(strSplitFruitsPrice[i]);
            }
            
            Arrays.sort(fruitsPrice);
            
            int ans = 0;
            
            for(int i=0; i<K; i++){
                ans = ans + fruitsPrice[i];
            }
            
            System.out.println(ans);
            
        }catch(Exception e){
            System.out.println(e);
        }
    }
} import java.io.*; io.* java import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        try{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            
            String strSplit[] = br.readLine().split(" ");
            int N = Integer.parseInt(strSplit[0]);
            int K = Integer.parseInt(strSplit[1]);
            
            String strSplitFruitsPrice[] = br.readLine().split(" ");
            int fruitsPrice[] = new int[N];
            for(int i=0; i<N; i++){
                fruitsPrice[i] = Integer.parseInt(strSplitFruitsPrice[i]);
            }
            
            Arrays.sort(fruitsPrice);
            
            int ans = 0;
            
            for(int i=0; i<K; i++){
                ans = ans + fruitsPrice[i];
            }
            
            System.out.println(ans);
            
        }catch(Exception e){
            System.out.println(e);
        }
    }
} Main public static void main(String[] args) throws Exception {
        try{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            
            String strSplit[] = br.readLine().split(" ");
            int N = Integer.parseInt(strSplit[0]);
            int K = Integer.parseInt(strSplit[1]);
            
            String strSplitFruitsPrice[] = br.readLine().split(" ");
            int fruitsPrice[] = new int[N];
            for(int i=0; i<N; i++){
                fruitsPrice[i] = Integer.parseInt(strSplitFruitsPrice[i]);
            }
            
            Arrays.sort(fruitsPrice);
            
            int ans = 0;
            
            for(int i=0; i<K; i++){
                ans = ans + fruitsPrice[i];
            }
            
            System.out.println(ans);
            
        }catch(Exception e){
            System.out.println(e);
        }
    } main {
        try{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            
            String strSplit[] = br.readLine().split(" ");
            int N = Integer.parseInt(strSplit[0]);
            int K = Integer.parseInt(strSplit[1]);
            
            String strSplitFruitsPrice[] = br.readLine().split(" ");
            int fruitsPrice[] = new int[N];
            for(int i=0; i<N; i++){
                fruitsPrice[i] = Integer.parseInt(strSplitFruitsPrice[i]);
            }
            
            Arrays.sort(fruitsPrice);
            
            int ans = 0;
            
            for(int i=0; i<K; i++){
                ans = ans + fruitsPrice[i];
            }
            
            System.out.println(ans);
            
        }catch(Exception e){
            System.out.println(e);
        }
    } try{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            
            String strSplit[] = br.readLine().split(" ");
            int N = Integer.parseInt(strSplit[0]);
            int K = Integer.parseInt(strSplit[1]);
            
            String strSplitFruitsPrice[] = br.readLine().split(" ");
            int fruitsPrice[] = new int[N];
            for(int i=0; i<N; i++){
                fruitsPrice[i] = Integer.parseInt(strSplitFruitsPrice[i]);
            }
            
            Arrays.sort(fruitsPrice);
            
            int ans = 0;
            
            for(int i=0; i<K; i++){
                ans = ans + fruitsPrice[i];
            }
            
            System.out.println(ans);
            
        }catch(Exception e){
            System.out.println(e);
        } catch(Exception e){
            System.out.println(e);
        } Exception e {
            System.out.println(e);
        } System.out.println(e) System.out.println System.out System System.out e {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            
            String strSplit[] = br.readLine().split(" ");
            int N = Integer.parseInt(strSplit[0]);
            int K = Integer.parseInt(strSplit[1]);
            
            String strSplitFruitsPrice[] = br.readLine().split(" ");
            int fruitsPrice[] = new int[N];
            for(int i=0; i<N; i++){
                fruitsPrice[i] = Integer.parseInt(strSplitFruitsPrice[i]);
            }
            
            Arrays.sort(fruitsPrice);
            
            int ans = 0;
            
            for(int i=0; i<K; i++){
                ans = ans + fruitsPrice[i];
            }
            
            System.out.println(ans);
            
        } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String strSplit[] = br.readLine().split(" "); strSplit br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int N = Integer.parseInt(strSplit[0]); N Integer.parseInt(strSplit[0]) Integer.parseInt Integer strSplit[0] strSplit 0 int K = Integer.parseInt(strSplit[1]); K Integer.parseInt(strSplit[1]) Integer.parseInt Integer strSplit[1] strSplit 1 String strSplitFruitsPrice[] = br.readLine().split(" "); strSplitFruitsPrice br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int fruitsPrice[] = new int[N]; fruitsPrice new int[N] N for(int i=0; i<N; i++){
                fruitsPrice[i] = Integer.parseInt(strSplitFruitsPrice[i]);
            } int i=0; int i=0; i 0 i<N i N i++ i++ i {
                fruitsPrice[i] = Integer.parseInt(strSplitFruitsPrice[i]);
            } {
                fruitsPrice[i] = Integer.parseInt(strSplitFruitsPrice[i]);
            } fruitsPrice[i] = Integer.parseInt(strSplitFruitsPrice[i]) fruitsPrice[i] fruitsPrice i Integer.parseInt(strSplitFruitsPrice[i]) Integer.parseInt Integer strSplitFruitsPrice[i] strSplitFruitsPrice i Arrays.sort(fruitsPrice) Arrays.sort Arrays fruitsPrice int ans = 0; ans 0 for(int i=0; i<K; i++){
                ans = ans + fruitsPrice[i];
            } int i=0; int i=0; i 0 i<K i K i++ i++ i {
                ans = ans + fruitsPrice[i];
            } {
                ans = ans + fruitsPrice[i];
            } ans = ans + fruitsPrice[i] ans ans + fruitsPrice[i] ans fruitsPrice[i] fruitsPrice i System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        try{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            
            String strSplit[] = br.readLine().split(" ");
            int N = Integer.parseInt(strSplit[0]);
            int K = Integer.parseInt(strSplit[1]);
            
            String strSplitFruitsPrice[] = br.readLine().split(" ");
            int fruitsPrice[] = new int[N];
            for(int i=0; i<N; i++){
                fruitsPrice[i] = Integer.parseInt(strSplitFruitsPrice[i]);
            }
            
            Arrays.sort(fruitsPrice);
            
            int ans = 0;
            
            for(int i=0; i<K; i++){
                ans = ans + fruitsPrice[i];
            }
            
            System.out.println(ans);
            
        }catch(Exception e){
            System.out.println(e);
        }
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        try{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            
            String strSplit[] = br.readLine().split(" ");
            int N = Integer.parseInt(strSplit[0]);
            int K = Integer.parseInt(strSplit[1]);
            
            String strSplitFruitsPrice[] = br.readLine().split(" ");
            int fruitsPrice[] = new int[N];
            for(int i=0; i<N; i++){
                fruitsPrice[i] = Integer.parseInt(strSplitFruitsPrice[i]);
            }
            
            Arrays.sort(fruitsPrice);
            
            int ans = 0;
            
            for(int i=0; i<K; i++){
                ans = ans + fruitsPrice[i];
            }
            
            System.out.println(ans);
            
        }catch(Exception e){
            System.out.println(e);
        }
    }
} Main
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        try{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            
            String strSplit[] = br.readLine().split(" ");
            int N = Integer.parseInt(strSplit[0]);
            int K = Integer.parseInt(strSplit[1]);
            
            String strSplitFruitsPrice[] = br.readLine().split(" ");
            int fruitsPrice[] = new int[N];
            for(int i=0; i<N; i++){
                fruitsPrice[i] = Integer.parseInt(strSplitFruitsPrice[i]);
            }
            
            Arrays.sort(fruitsPrice);
            
            int ans = 0;
            
            for(int i=0; i<K; i++){
                ans = ans + fruitsPrice[i];
            }
            
            System.out.println(ans);
            
        }catch(Exception e){
            System.out.println(e);
        }
    }
}