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[] values = new int[N];
        for (int i = 0; i < N; i++) {
            values[i] = sc.nextInt();
        }
        sc.close();

        Arrays.sort(values);
        int allValues = 0;
        for (int i = 0; i < K; i++) {
            allValues += values[i];
        }
        System.out.println(allValues);

    }
} 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[] values = new int[N];
        for (int i = 0; i < N; i++) {
            values[i] = sc.nextInt();
        }
        sc.close();

        Arrays.sort(values);
        int allValues = 0;
        for (int i = 0; i < K; i++) {
            allValues += values[i];
        }
        System.out.println(allValues);

    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] values = new int[N];
        for (int i = 0; i < N; i++) {
            values[i] = sc.nextInt();
        }
        sc.close();

        Arrays.sort(values);
        int allValues = 0;
        for (int i = 0; i < K; i++) {
            allValues += values[i];
        }
        System.out.println(allValues);

    } main {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] values = new int[N];
        for (int i = 0; i < N; i++) {
            values[i] = sc.nextInt();
        }
        sc.close();

        Arrays.sort(values);
        int allValues = 0;
        for (int i = 0; i < K; i++) {
            allValues += values[i];
        }
        System.out.println(allValues);

    } 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[] values = new int[N]; values new int[N] N for (int i = 0; i < N; i++) {
            values[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            values[i] = sc.nextInt();
        } {
            values[i] = sc.nextInt();
        } values[i] = sc.nextInt() values[i] values i sc.nextInt() sc.nextInt sc sc.close() sc.close sc Arrays.sort(values) Arrays.sort Arrays values int allValues = 0; allValues 0 for (int i = 0; i < K; i++) {
            allValues += values[i];
        } int i = 0; int i = 0; i 0 i < K i K i++ i++ i {
            allValues += values[i];
        } {
            allValues += values[i];
        } allValues += values[i] allValues values[i] values i System.out.println(allValues) System.out.println System.out System System.out allValues 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[] values = new int[N];
        for (int i = 0; i < N; i++) {
            values[i] = sc.nextInt();
        }
        sc.close();

        Arrays.sort(values);
        int allValues = 0;
        for (int i = 0; i < K; i++) {
            allValues += values[i];
        }
        System.out.println(allValues);

    }
} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] values = new int[N];
        for (int i = 0; i < N; i++) {
            values[i] = sc.nextInt();
        }
        sc.close();

        Arrays.sort(values);
        int allValues = 0;
        for (int i = 0; i < K; i++) {
            allValues += values[i];
        }
        System.out.println(allValues);

    }
} 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[] values = new int[N];
        for (int i = 0; i < N; i++) {
            values[i] = sc.nextInt();
        }
        sc.close();

        Arrays.sort(values);
        int allValues = 0;
        for (int i = 0; i < K; i++) {
            allValues += values[i];
        }
        System.out.println(allValues);

    }
}
