import java.util.*;
import java.util.stream.Collector;
import java.util.stream.Collectors;

public class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int K = sc.nextInt();

        List<Integer> p = new ArrayList<Integer>();
        for (int i = 0; i < N; i++) {
            p.add(sc.nextInt());
        }

        p = p.stream().sorted().collect(Collectors.toList());

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

        System.out.println(sum);
    }
} import java.util.*; util.* java import java.util.stream.Collector; Collector java.util.stream import java.util.stream.Collectors; Collectors java.util.stream public class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int K = sc.nextInt();

        List<Integer> p = new ArrayList<Integer>();
        for (int i = 0; i < N; i++) {
            p.add(sc.nextInt());
        }

        p = p.stream().sorted().collect(Collectors.toList());

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

        System.out.println(sum);
    }
} Main public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int K = sc.nextInt();

        List<Integer> p = new ArrayList<Integer>();
        for (int i = 0; i < N; i++) {
            p.add(sc.nextInt());
        }

        p = p.stream().sorted().collect(Collectors.toList());

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

        System.out.println(sum);
    } main {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int K = sc.nextInt();

        List<Integer> p = new ArrayList<Integer>();
        for (int i = 0; i < N; i++) {
            p.add(sc.nextInt());
        }

        p = p.stream().sorted().collect(Collectors.toList());

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

        System.out.println(sum);
    } 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 List<Integer> p = new ArrayList<Integer>(); p new ArrayList<Integer>() for (int i = 0; i < N; i++) {
            p.add(sc.nextInt());
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            p.add(sc.nextInt());
        } {
            p.add(sc.nextInt());
        } p.add(sc.nextInt()) p.add p sc.nextInt() sc.nextInt sc p = p.stream().sorted().collect(Collectors.toList()) p p.stream().sorted().collect(Collectors.toList()) p.stream().sorted().collect p.stream().sorted() p.stream().sorted p.stream() p.stream p Collectors.toList() Collectors.toList Collectors int sum = 0; sum 0 for (int i = 0; i < K; i++) {
            sum += p.get(i);
        } int i = 0; int i = 0; i 0 i < K i K i++ i++ i {
            sum += p.get(i);
        } {
            sum += p.get(i);
        } sum += p.get(i) sum p.get(i) p.get p i 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 sc = new Scanner(System.in);

        int N = sc.nextInt();
        int K = sc.nextInt();

        List<Integer> p = new ArrayList<Integer>();
        for (int i = 0; i < N; i++) {
            p.add(sc.nextInt());
        }

        p = p.stream().sorted().collect(Collectors.toList());

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

        System.out.println(sum);
    }
} public class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int K = sc.nextInt();

        List<Integer> p = new ArrayList<Integer>();
        for (int i = 0; i < N; i++) {
            p.add(sc.nextInt());
        }

        p = p.stream().sorted().collect(Collectors.toList());

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

        System.out.println(sum);
    }
} Main
import java.util.*;
import java.util.stream.Collector;
import java.util.stream.Collectors;

public class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int K = sc.nextInt();

        List<Integer> p = new ArrayList<Integer>();
        for (int i = 0; i < N; i++) {
            p.add(sc.nextInt());
        }

        p = p.stream().sorted().collect(Collectors.toList());

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

        System.out.println(sum);
    }
}