import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final 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();
        }
        sc.close();

        final ArrayList<Integer> list = new ArrayList<Integer>();
        for (final int t : p)
            list.add(t);

        Collections.sort(list);

        int sum = 0;

        for (int i = 0; i < K; i++) {
            sum += list.get(i);
        }

        System.out.println(sum);

        return;
    }
} import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(final String[] args) {
        final 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();
        }
        sc.close();

        final ArrayList<Integer> list = new ArrayList<Integer>();
        for (final int t : p)
            list.add(t);

        Collections.sort(list);

        int sum = 0;

        for (int i = 0; i < K; i++) {
            sum += list.get(i);
        }

        System.out.println(sum);

        return;
    }
} Main public static void main(final String[] args) {
        final 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();
        }
        sc.close();

        final ArrayList<Integer> list = new ArrayList<Integer>();
        for (final int t : p)
            list.add(t);

        Collections.sort(list);

        int sum = 0;

        for (int i = 0; i < K; i++) {
            sum += list.get(i);
        }

        System.out.println(sum);

        return;
    } main {
        final 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();
        }
        sc.close();

        final ArrayList<Integer> list = new ArrayList<Integer>();
        for (final int t : p)
            list.add(t);

        Collections.sort(list);

        int sum = 0;

        for (int i = 0; i < K; i++) {
            sum += list.get(i);
        }

        System.out.println(sum);

        return;
    } final 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 sc.close() sc.close sc final ArrayList<Integer> list = new ArrayList<Integer>(); list new ArrayList<Integer>() for (final int t : p)
            list.add(t); final int t p list.add(t); list.add(t) list.add list t Collections.sort(list) Collections.sort Collections list int sum = 0; sum 0 for (int i = 0; i < K; i++) {
            sum += list.get(i);
        } int i = 0; int i = 0; i 0 i < K i K i++ i++ i {
            sum += list.get(i);
        } {
            sum += list.get(i);
        } sum += list.get(i) sum list.get(i) list.get list i System.out.println(sum) System.out.println System.out System System.out sum return; final String[] args args public class Main {
    public static void main(final String[] args) {
        final 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();
        }
        sc.close();

        final ArrayList<Integer> list = new ArrayList<Integer>();
        for (final int t : p)
            list.add(t);

        Collections.sort(list);

        int sum = 0;

        for (int i = 0; i < K; i++) {
            sum += list.get(i);
        }

        System.out.println(sum);

        return;
    }
} public class Main {
    public static void main(final String[] args) {
        final 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();
        }
        sc.close();

        final ArrayList<Integer> list = new ArrayList<Integer>();
        for (final int t : p)
            list.add(t);

        Collections.sort(list);

        int sum = 0;

        for (int i = 0; i < K; i++) {
            sum += list.get(i);
        }

        System.out.println(sum);

        return;
    }
} Main
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final 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();
        }
        sc.close();

        final ArrayList<Integer> list = new ArrayList<Integer>();
        for (final int t : p)
            list.add(t);

        Collections.sort(list);

        int sum = 0;

        for (int i = 0; i < K; i++) {
            sum += list.get(i);
        }

        System.out.println(sum);

        return;
    }
}