import java.util.*;

public class Main {
    public static void main(final String[] args) {
        final Scanner sc = new Scanner(System.in);
        // 整数の入力
        // final int a = sc.nextInt();
        // 文字列の入力
        // final String s1 = sc.next();
        final int N = Integer.parseInt(sc.next());
        final int K = Integer.parseInt(sc.next());
        int result = 0;
        int[] pricelist = new int[N];
        for (int i = 0; i < N; i++) {
            pricelist[i] = Integer.parseInt(sc.next());
        }
        sc.close();
        Arrays.sort(pricelist);
        for (int i = 0; i < K; i++) {
            result = result + pricelist[i];
        }
        System.out.println(result);
    }
} import java.util.*; util.* java public class Main {
    public static void main(final String[] args) {
        final Scanner sc = new Scanner(System.in);
        // 整数の入力
        // final int a = sc.nextInt();
        // 文字列の入力
        // final String s1 = sc.next();
        final int N = Integer.parseInt(sc.next());
        final int K = Integer.parseInt(sc.next());
        int result = 0;
        int[] pricelist = new int[N];
        for (int i = 0; i < N; i++) {
            pricelist[i] = Integer.parseInt(sc.next());
        }
        sc.close();
        Arrays.sort(pricelist);
        for (int i = 0; i < K; i++) {
            result = result + pricelist[i];
        }
        System.out.println(result);
    }
} Main public static void main(final String[] args) {
        final Scanner sc = new Scanner(System.in);
        // 整数の入力
        // final int a = sc.nextInt();
        // 文字列の入力
        // final String s1 = sc.next();
        final int N = Integer.parseInt(sc.next());
        final int K = Integer.parseInt(sc.next());
        int result = 0;
        int[] pricelist = new int[N];
        for (int i = 0; i < N; i++) {
            pricelist[i] = Integer.parseInt(sc.next());
        }
        sc.close();
        Arrays.sort(pricelist);
        for (int i = 0; i < K; i++) {
            result = result + pricelist[i];
        }
        System.out.println(result);
    } main {
        final Scanner sc = new Scanner(System.in);
        // 整数の入力
        // final int a = sc.nextInt();
        // 文字列の入力
        // final String s1 = sc.next();
        final int N = Integer.parseInt(sc.next());
        final int K = Integer.parseInt(sc.next());
        int result = 0;
        int[] pricelist = new int[N];
        for (int i = 0; i < N; i++) {
            pricelist[i] = Integer.parseInt(sc.next());
        }
        sc.close();
        Arrays.sort(pricelist);
        for (int i = 0; i < K; i++) {
            result = result + pricelist[i];
        }
        System.out.println(result);
    } final Scanner sc = new Scanner(System.in); sc new Scanner(System.in) final int N = Integer.parseInt(sc.next()); N Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc final int K = Integer.parseInt(sc.next()); K Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int result = 0; result 0 int[] pricelist = new int[N]; pricelist new int[N] N for (int i = 0; i < N; i++) {
            pricelist[i] = Integer.parseInt(sc.next());
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            pricelist[i] = Integer.parseInt(sc.next());
        } {
            pricelist[i] = Integer.parseInt(sc.next());
        } pricelist[i] = Integer.parseInt(sc.next()) pricelist[i] pricelist i Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc sc.close() sc.close sc Arrays.sort(pricelist) Arrays.sort Arrays pricelist for (int i = 0; i < K; i++) {
            result = result + pricelist[i];
        } int i = 0; int i = 0; i 0 i < K i K i++ i++ i {
            result = result + pricelist[i];
        } {
            result = result + pricelist[i];
        } result = result + pricelist[i] result result + pricelist[i] result pricelist[i] pricelist i System.out.println(result) System.out.println System.out System System.out result final String[] args args public class Main {
    public static void main(final String[] args) {
        final Scanner sc = new Scanner(System.in);
        // 整数の入力
        // final int a = sc.nextInt();
        // 文字列の入力
        // final String s1 = sc.next();
        final int N = Integer.parseInt(sc.next());
        final int K = Integer.parseInt(sc.next());
        int result = 0;
        int[] pricelist = new int[N];
        for (int i = 0; i < N; i++) {
            pricelist[i] = Integer.parseInt(sc.next());
        }
        sc.close();
        Arrays.sort(pricelist);
        for (int i = 0; i < K; i++) {
            result = result + pricelist[i];
        }
        System.out.println(result);
    }
} public class Main {
    public static void main(final String[] args) {
        final Scanner sc = new Scanner(System.in);
        // 整数の入力
        // final int a = sc.nextInt();
        // 文字列の入力
        // final String s1 = sc.next();
        final int N = Integer.parseInt(sc.next());
        final int K = Integer.parseInt(sc.next());
        int result = 0;
        int[] pricelist = new int[N];
        for (int i = 0; i < N; i++) {
            pricelist[i] = Integer.parseInt(sc.next());
        }
        sc.close();
        Arrays.sort(pricelist);
        for (int i = 0; i < K; i++) {
            result = result + pricelist[i];
        }
        System.out.println(result);
    }
} Main
import java.util.*;

public class Main {
    public static void main(final String[] args) {
        final Scanner sc = new Scanner(System.in);
        // 整数の入力
        // final int a = sc.nextInt();
        // 文字列の入力
        // final String s1 = sc.next();
        final int N = Integer.parseInt(sc.next());
        final int K = Integer.parseInt(sc.next());
        int result = 0;
        int[] pricelist = new int[N];
        for (int i = 0; i < N; i++) {
            pricelist[i] = Integer.parseInt(sc.next());
        }
        sc.close();
        Arrays.sort(pricelist);
        for (int i = 0; i < K; i++) {
            result = result + pricelist[i];
        }
        System.out.println(result);
    }
}