import java.util.*;

public class Main {

    public static void main(String args[]) {


        Scanner scan = new Scanner(System.in);

        int n = scan.nextInt();
        int k = scan.nextInt();
        int sum =0;
        List<Integer> list = new ArrayList<>();

        for (int i=0; i<n; i++) {
            int p = scan.nextInt();
            list.add(i, p);
        }

        Collections.sort(list);

        for (int j =0; j<k; j++) {
            sum += list.get(j);
        }

        System.out.println(sum);

    }

} import java.util.*; util.* java public class Main {

    public static void main(String args[]) {


        Scanner scan = new Scanner(System.in);

        int n = scan.nextInt();
        int k = scan.nextInt();
        int sum =0;
        List<Integer> list = new ArrayList<>();

        for (int i=0; i<n; i++) {
            int p = scan.nextInt();
            list.add(i, p);
        }

        Collections.sort(list);

        for (int j =0; j<k; j++) {
            sum += list.get(j);
        }

        System.out.println(sum);

    }

} Main public static void main(String args[]) {


        Scanner scan = new Scanner(System.in);

        int n = scan.nextInt();
        int k = scan.nextInt();
        int sum =0;
        List<Integer> list = new ArrayList<>();

        for (int i=0; i<n; i++) {
            int p = scan.nextInt();
            list.add(i, p);
        }

        Collections.sort(list);

        for (int j =0; j<k; j++) {
            sum += list.get(j);
        }

        System.out.println(sum);

    } main {


        Scanner scan = new Scanner(System.in);

        int n = scan.nextInt();
        int k = scan.nextInt();
        int sum =0;
        List<Integer> list = new ArrayList<>();

        for (int i=0; i<n; i++) {
            int p = scan.nextInt();
            list.add(i, p);
        }

        Collections.sort(list);

        for (int j =0; j<k; j++) {
            sum += list.get(j);
        }

        System.out.println(sum);

    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan int k = scan.nextInt(); k scan.nextInt() scan.nextInt scan int sum =0; sum 0 List<Integer> list = new ArrayList<>(); list new ArrayList<>() for (int i=0; i<n; i++) {
            int p = scan.nextInt();
            list.add(i, p);
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
            int p = scan.nextInt();
            list.add(i, p);
        } {
            int p = scan.nextInt();
            list.add(i, p);
        } int p = scan.nextInt(); p scan.nextInt() scan.nextInt scan list.add(i, p) list.add list i p Collections.sort(list) Collections.sort Collections list for (int j =0; j<k; j++) {
            sum += list.get(j);
        } int j =0; int j =0; j 0 j<k j k j++ j++ j {
            sum += list.get(j);
        } {
            sum += list.get(j);
        } sum += list.get(j) sum list.get(j) list.get list j 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[]) {


        Scanner scan = new Scanner(System.in);

        int n = scan.nextInt();
        int k = scan.nextInt();
        int sum =0;
        List<Integer> list = new ArrayList<>();

        for (int i=0; i<n; i++) {
            int p = scan.nextInt();
            list.add(i, p);
        }

        Collections.sort(list);

        for (int j =0; j<k; j++) {
            sum += list.get(j);
        }

        System.out.println(sum);

    }

} public class Main {

    public static void main(String args[]) {


        Scanner scan = new Scanner(System.in);

        int n = scan.nextInt();
        int k = scan.nextInt();
        int sum =0;
        List<Integer> list = new ArrayList<>();

        for (int i=0; i<n; i++) {
            int p = scan.nextInt();
            list.add(i, p);
        }

        Collections.sort(list);

        for (int j =0; j<k; j++) {
            sum += list.get(j);
        }

        System.out.println(sum);

    }

} Main
import java.util.*;

public class Main {

    public static void main(String args[]) {


        Scanner scan = new Scanner(System.in);

        int n = scan.nextInt();
        int k = scan.nextInt();
        int sum =0;
        List<Integer> list = new ArrayList<>();

        for (int i=0; i<n; i++) {
            int p = scan.nextInt();
            list.add(i, p);
        }

        Collections.sort(list);

        for (int j =0; j<k; j++) {
            sum += list.get(j);
        }

        System.out.println(sum);

    }

}