import java.util.*;
public class Main { 
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int o=0;
        int n=sc.nextInt();
        int k=sc.nextInt();
      PriorityQueue<Integer> p=new PriorityQueue<>();
      	for(int i=0;i<n;i++){
    		p.offer(sc.nextInt());
		}
        for(int j=0;j<k;j++){
          	o+=p.poll();
    	}
      System.out.println(o);
    }
    
} import java.util.*; util.* java public class Main { 
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int o=0;
        int n=sc.nextInt();
        int k=sc.nextInt();
      PriorityQueue<Integer> p=new PriorityQueue<>();
      	for(int i=0;i<n;i++){
    		p.offer(sc.nextInt());
		}
        for(int j=0;j<k;j++){
          	o+=p.poll();
    	}
      System.out.println(o);
    }
    
} Main public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int o=0;
        int n=sc.nextInt();
        int k=sc.nextInt();
      PriorityQueue<Integer> p=new PriorityQueue<>();
      	for(int i=0;i<n;i++){
    		p.offer(sc.nextInt());
		}
        for(int j=0;j<k;j++){
          	o+=p.poll();
    	}
      System.out.println(o);
    } main {
        Scanner sc=new Scanner(System.in);
        int o=0;
        int n=sc.nextInt();
        int k=sc.nextInt();
      PriorityQueue<Integer> p=new PriorityQueue<>();
      	for(int i=0;i<n;i++){
    		p.offer(sc.nextInt());
		}
        for(int j=0;j<k;j++){
          	o+=p.poll();
    	}
      System.out.println(o);
    } Scanner sc=new Scanner(System.in); sc new Scanner(System.in) int o=0; o 0 int n=sc.nextInt(); n sc.nextInt() sc.nextInt sc int k=sc.nextInt(); k sc.nextInt() sc.nextInt sc PriorityQueue<Integer> p=new PriorityQueue<>(); p new PriorityQueue<>() for(int i=0;i<n;i++){
    		p.offer(sc.nextInt());
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
    		p.offer(sc.nextInt());
		} {
    		p.offer(sc.nextInt());
		} p.offer(sc.nextInt()) p.offer p sc.nextInt() sc.nextInt sc for(int j=0;j<k;j++){
          	o+=p.poll();
    	} int j=0; int j=0; j 0 j<k j k j++ j++ j {
          	o+=p.poll();
    	} {
          	o+=p.poll();
    	} o+=p.poll() o p.poll() p.poll p System.out.println(o) System.out.println System.out System System.out o String[] args args public class Main { 
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int o=0;
        int n=sc.nextInt();
        int k=sc.nextInt();
      PriorityQueue<Integer> p=new PriorityQueue<>();
      	for(int i=0;i<n;i++){
    		p.offer(sc.nextInt());
		}
        for(int j=0;j<k;j++){
          	o+=p.poll();
    	}
      System.out.println(o);
    }
    
} public class Main { 
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int o=0;
        int n=sc.nextInt();
        int k=sc.nextInt();
      PriorityQueue<Integer> p=new PriorityQueue<>();
      	for(int i=0;i<n;i++){
    		p.offer(sc.nextInt());
		}
        for(int j=0;j<k;j++){
          	o+=p.poll();
    	}
      System.out.println(o);
    }
    
} Main
import java.util.*;
public class Main { 
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int o=0;
        int n=sc.nextInt();
        int k=sc.nextInt();
      PriorityQueue<Integer> p=new PriorityQueue<>();
      	for(int i=0;i<n;i++){
    		p.offer(sc.nextInt());
		}
        for(int j=0;j<k;j++){
          	o+=p.poll();
    	}
      System.out.println(o);
    }
    
}