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