import java.util.Map.Entry;
import java.util.*;
import java.math.*;
import org.w3c.dom.css.Counter;
  
public class Main{
    public static void main(final String[] args){
       
        final Scanner sc = new Scanner(System.in);
        //int N =sc.nextInt();
        ArrayList<Integer>  allmen =new ArrayList <Integer>();
        //HashSet doubled =new HashSet<Integer>();
        
        //Set<?> yourHashSet = new HashSet<>();
        //List<?> sortedList = new ArrayList<>(yourHashSet);
        
        int N = sc.nextInt();
        int K = sc.nextInt();
        int counter =0;
        //HashSet doubled =new HashSet<Integer>();
        for(int i =0;i <N;i++){
            allmen.add(i, sc.nextInt());
        }
        Collections.sort(allmen);
        for(int i =0;i <K;i++){
            counter += allmen.get(i);
        }

        System.out.println(counter);


        //System.out.println(ans);
    }
}
    

/*         for(int i=0;i<N-1;i++){
            int target = sc.nextInt();
            if(target < blocker){
                blocker = target;
            }
            if(allmen.contains(target)==false){
                if(target%blocker!=0){
                    allmen.add(target);
                } 
            }
                else{
                    doubled.add(target);
                }       
            
        }
        Collections.sort(allmen);
         //画面表示
        for(int i=0;i <=allmen.size()-1;i++){
            boolean judge = true;
            int target = allmen.get(i);
            if(doubled.contains(target)==false){
                for(int X= 0;X<i;X++){
                    if(target% allmen.get(X)==0){
                        judge = false;
                        break;
                    }
                }
            }else{
                judge = false;
            }
            if(judge == true){
                ans++;
            }
        } */

     import java.util.Map.Entry; Entry java.util.Map import java.util.*; util.* java import java.math.*; math.* java import org.w3c.dom.css.Counter; Counter org.w3c.dom.css public class Main{
    public static void main(final String[] args){
       
        final Scanner sc = new Scanner(System.in);
        //int N =sc.nextInt();
        ArrayList<Integer>  allmen =new ArrayList <Integer>();
        //HashSet doubled =new HashSet<Integer>();
        
        //Set<?> yourHashSet = new HashSet<>();
        //List<?> sortedList = new ArrayList<>(yourHashSet);
        
        int N = sc.nextInt();
        int K = sc.nextInt();
        int counter =0;
        //HashSet doubled =new HashSet<Integer>();
        for(int i =0;i <N;i++){
            allmen.add(i, sc.nextInt());
        }
        Collections.sort(allmen);
        for(int i =0;i <K;i++){
            counter += allmen.get(i);
        }

        System.out.println(counter);


        //System.out.println(ans);
    }
} Main public static void main(final String[] args){
       
        final Scanner sc = new Scanner(System.in);
        //int N =sc.nextInt();
        ArrayList<Integer>  allmen =new ArrayList <Integer>();
        //HashSet doubled =new HashSet<Integer>();
        
        //Set<?> yourHashSet = new HashSet<>();
        //List<?> sortedList = new ArrayList<>(yourHashSet);
        
        int N = sc.nextInt();
        int K = sc.nextInt();
        int counter =0;
        //HashSet doubled =new HashSet<Integer>();
        for(int i =0;i <N;i++){
            allmen.add(i, sc.nextInt());
        }
        Collections.sort(allmen);
        for(int i =0;i <K;i++){
            counter += allmen.get(i);
        }

        System.out.println(counter);


        //System.out.println(ans);
    } main {
       
        final Scanner sc = new Scanner(System.in);
        //int N =sc.nextInt();
        ArrayList<Integer>  allmen =new ArrayList <Integer>();
        //HashSet doubled =new HashSet<Integer>();
        
        //Set<?> yourHashSet = new HashSet<>();
        //List<?> sortedList = new ArrayList<>(yourHashSet);
        
        int N = sc.nextInt();
        int K = sc.nextInt();
        int counter =0;
        //HashSet doubled =new HashSet<Integer>();
        for(int i =0;i <N;i++){
            allmen.add(i, sc.nextInt());
        }
        Collections.sort(allmen);
        for(int i =0;i <K;i++){
            counter += allmen.get(i);
        }

        System.out.println(counter);


        //System.out.println(ans);
    } final Scanner sc = new Scanner(System.in); sc new Scanner(System.in) ArrayList<Integer>  allmen =new ArrayList <Integer>(); allmen new ArrayList <Integer>() int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int K = sc.nextInt(); K sc.nextInt() sc.nextInt sc int counter =0; counter 0 for(int i =0;i <N;i++){
            allmen.add(i, sc.nextInt());
        } int i =0; int i =0; i 0 i <N i N i++ i++ i {
            allmen.add(i, sc.nextInt());
        } {
            allmen.add(i, sc.nextInt());
        } allmen.add(i, sc.nextInt()) allmen.add allmen i sc.nextInt() sc.nextInt sc Collections.sort(allmen) Collections.sort Collections allmen for(int i =0;i <K;i++){
            counter += allmen.get(i);
        } int i =0; int i =0; i 0 i <K i K i++ i++ i {
            counter += allmen.get(i);
        } {
            counter += allmen.get(i);
        } counter += allmen.get(i) counter allmen.get(i) allmen.get allmen i System.out.println(counter) System.out.println System.out System System.out counter final String[] args args public class Main{
    public static void main(final String[] args){
       
        final Scanner sc = new Scanner(System.in);
        //int N =sc.nextInt();
        ArrayList<Integer>  allmen =new ArrayList <Integer>();
        //HashSet doubled =new HashSet<Integer>();
        
        //Set<?> yourHashSet = new HashSet<>();
        //List<?> sortedList = new ArrayList<>(yourHashSet);
        
        int N = sc.nextInt();
        int K = sc.nextInt();
        int counter =0;
        //HashSet doubled =new HashSet<Integer>();
        for(int i =0;i <N;i++){
            allmen.add(i, sc.nextInt());
        }
        Collections.sort(allmen);
        for(int i =0;i <K;i++){
            counter += allmen.get(i);
        }

        System.out.println(counter);


        //System.out.println(ans);
    }
} public class Main{
    public static void main(final String[] args){
       
        final Scanner sc = new Scanner(System.in);
        //int N =sc.nextInt();
        ArrayList<Integer>  allmen =new ArrayList <Integer>();
        //HashSet doubled =new HashSet<Integer>();
        
        //Set<?> yourHashSet = new HashSet<>();
        //List<?> sortedList = new ArrayList<>(yourHashSet);
        
        int N = sc.nextInt();
        int K = sc.nextInt();
        int counter =0;
        //HashSet doubled =new HashSet<Integer>();
        for(int i =0;i <N;i++){
            allmen.add(i, sc.nextInt());
        }
        Collections.sort(allmen);
        for(int i =0;i <K;i++){
            counter += allmen.get(i);
        }

        System.out.println(counter);


        //System.out.println(ans);
    }
} Main
import java.util.Map.Entry;
import java.util.*;
import java.math.*;
import org.w3c.dom.css.Counter;
  
public class Main{
    public static void main(final String[] args){
       
        final Scanner sc = new Scanner(System.in);
        //int N =sc.nextInt();
        ArrayList<Integer>  allmen =new ArrayList <Integer>();
        //HashSet doubled =new HashSet<Integer>();
        
        //Set<?> yourHashSet = new HashSet<>();
        //List<?> sortedList = new ArrayList<>(yourHashSet);
        
        int N = sc.nextInt();
        int K = sc.nextInt();
        int counter =0;
        //HashSet doubled =new HashSet<Integer>();
        for(int i =0;i <N;i++){
            allmen.add(i, sc.nextInt());
        }
        Collections.sort(allmen);
        for(int i =0;i <K;i++){
            counter += allmen.get(i);
        }

        System.out.println(counter);


        //System.out.println(ans);
    }
}
    

/*         for(int i=0;i<N-1;i++){
            int target = sc.nextInt();
            if(target < blocker){
                blocker = target;
            }
            if(allmen.contains(target)==false){
                if(target%blocker!=0){
                    allmen.add(target);
                } 
            }
                else{
                    doubled.add(target);
                }       
            
        }
        Collections.sort(allmen);
         //画面表示
        for(int i=0;i <=allmen.size()-1;i++){
            boolean judge = true;
            int target = allmen.get(i);
            if(doubled.contains(target)==false){
                for(int X= 0;X<i;X++){
                    if(target% allmen.get(X)==0){
                        judge = false;
                        break;
                    }
                }
            }else{
                judge = false;
            }
            if(judge == true){
                ans++;
            }
        } */

    