import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner s = new Scanner(System.in);
        int N = s.nextInt();
        int K = s.nextInt();
        int[] foo = new int[N];
         for(int i = 0; i < N; i++) {
            foo[i] = s.nextInt();
        }
        
        int sum = 0; 
        Arrays.sort(foo);
        
        for(int i = 0; i < K;i++) {
            sum+= foo[i];
        }
        System.out.println(sum);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        Scanner s = new Scanner(System.in);
        int N = s.nextInt();
        int K = s.nextInt();
        int[] foo = new int[N];
         for(int i = 0; i < N; i++) {
            foo[i] = s.nextInt();
        }
        
        int sum = 0; 
        Arrays.sort(foo);
        
        for(int i = 0; i < K;i++) {
            sum+= foo[i];
        }
        System.out.println(sum);
    }
} Main public static void main(String[] args) throws Exception {
        Scanner s = new Scanner(System.in);
        int N = s.nextInt();
        int K = s.nextInt();
        int[] foo = new int[N];
         for(int i = 0; i < N; i++) {
            foo[i] = s.nextInt();
        }
        
        int sum = 0; 
        Arrays.sort(foo);
        
        for(int i = 0; i < K;i++) {
            sum+= foo[i];
        }
        System.out.println(sum);
    } main {
        Scanner s = new Scanner(System.in);
        int N = s.nextInt();
        int K = s.nextInt();
        int[] foo = new int[N];
         for(int i = 0; i < N; i++) {
            foo[i] = s.nextInt();
        }
        
        int sum = 0; 
        Arrays.sort(foo);
        
        for(int i = 0; i < K;i++) {
            sum+= foo[i];
        }
        System.out.println(sum);
    } Scanner s = new Scanner(System.in); s new Scanner(System.in) int N = s.nextInt(); N s.nextInt() s.nextInt s int K = s.nextInt(); K s.nextInt() s.nextInt s int[] foo = new int[N]; foo new int[N] N for(int i = 0; i < N; i++) {
            foo[i] = s.nextInt();
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            foo[i] = s.nextInt();
        } {
            foo[i] = s.nextInt();
        } foo[i] = s.nextInt() foo[i] foo i s.nextInt() s.nextInt s int sum = 0; sum 0 Arrays.sort(foo) Arrays.sort Arrays foo for(int i = 0; i < K;i++) {
            sum+= foo[i];
        } int i = 0; int i = 0; i 0 i < K i K i++ i++ i {
            sum+= foo[i];
        } {
            sum+= foo[i];
        } sum+= foo[i] sum foo[i] foo i System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        Scanner s = new Scanner(System.in);
        int N = s.nextInt();
        int K = s.nextInt();
        int[] foo = new int[N];
         for(int i = 0; i < N; i++) {
            foo[i] = s.nextInt();
        }
        
        int sum = 0; 
        Arrays.sort(foo);
        
        for(int i = 0; i < K;i++) {
            sum+= foo[i];
        }
        System.out.println(sum);
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        Scanner s = new Scanner(System.in);
        int N = s.nextInt();
        int K = s.nextInt();
        int[] foo = new int[N];
         for(int i = 0; i < N; i++) {
            foo[i] = s.nextInt();
        }
        
        int sum = 0; 
        Arrays.sort(foo);
        
        for(int i = 0; i < K;i++) {
            sum+= foo[i];
        }
        System.out.println(sum);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner s = new Scanner(System.in);
        int N = s.nextInt();
        int K = s.nextInt();
        int[] foo = new int[N];
         for(int i = 0; i < N; i++) {
            foo[i] = s.nextInt();
        }
        
        int sum = 0; 
        Arrays.sort(foo);
        
        for(int i = 0; i < K;i++) {
            sum+= foo[i];
        }
        System.out.println(sum);
    }
}
