import java.util.Arrays;
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        final int N = sc.nextInt();
        final int K = sc.nextInt();
        
        final int[] p = new int[N];
        for (int i = 0; i < N; i++) {
            p[i] = sc.nextInt();
        }
        
        int answer = Arrays.stream(p).sorted().limit(K).sum();
        
        System.out.println(answer);
    }
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        final int N = sc.nextInt();
        final int K = sc.nextInt();
        
        final int[] p = new int[N];
        for (int i = 0; i < N; i++) {
            p[i] = sc.nextInt();
        }
        
        int answer = Arrays.stream(p).sorted().limit(K).sum();
        
        System.out.println(answer);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        final int N = sc.nextInt();
        final int K = sc.nextInt();
        
        final int[] p = new int[N];
        for (int i = 0; i < N; i++) {
            p[i] = sc.nextInt();
        }
        
        int answer = Arrays.stream(p).sorted().limit(K).sum();
        
        System.out.println(answer);
    } main {
        Scanner sc = new Scanner(System.in);
        
        final int N = sc.nextInt();
        final int K = sc.nextInt();
        
        final int[] p = new int[N];
        for (int i = 0; i < N; i++) {
            p[i] = sc.nextInt();
        }
        
        int answer = Arrays.stream(p).sorted().limit(K).sum();
        
        System.out.println(answer);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) final int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc final int K = sc.nextInt(); K sc.nextInt() sc.nextInt sc final int[] p = new int[N]; p new int[N] N for (int i = 0; i < N; i++) {
            p[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            p[i] = sc.nextInt();
        } {
            p[i] = sc.nextInt();
        } p[i] = sc.nextInt() p[i] p i sc.nextInt() sc.nextInt sc int answer = Arrays.stream(p).sorted().limit(K).sum(); answer Arrays.stream(p).sorted().limit(K).sum() Arrays.stream(p).sorted().limit(K).sum Arrays.stream(p).sorted().limit(K) Arrays.stream(p).sorted().limit Arrays.stream(p).sorted() Arrays.stream(p).sorted Arrays.stream(p) Arrays.stream Arrays p K System.out.println(answer) System.out.println System.out System System.out answer String[] args args public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        final int N = sc.nextInt();
        final int K = sc.nextInt();
        
        final int[] p = new int[N];
        for (int i = 0; i < N; i++) {
            p[i] = sc.nextInt();
        }
        
        int answer = Arrays.stream(p).sorted().limit(K).sum();
        
        System.out.println(answer);
    }
} public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        final int N = sc.nextInt();
        final int K = sc.nextInt();
        
        final int[] p = new int[N];
        for (int i = 0; i < N; i++) {
            p[i] = sc.nextInt();
        }
        
        int answer = Arrays.stream(p).sorted().limit(K).sum();
        
        System.out.println(answer);
    }
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        final int N = sc.nextInt();
        final int K = sc.nextInt();
        
        final int[] p = new int[N];
        for (int i = 0; i < N; i++) {
            p[i] = sc.nextInt();
        }
        
        int answer = Arrays.stream(p).sorted().limit(K).sum();
        
        System.out.println(answer);
    }
}
