import java.util.Arrays;
import java.util.Scanner;

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

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

        int[] p = new int[N];

        for (int i = 0; i < N; i++) {
            p[i] = scanner.nextInt();
        }

        Arrays.sort(p);

        int ans = 0;

        for (int i = 0; i < K; i++) {
            ans += p[i];
        }

        System.out.println(ans);
    }
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] var0) {
        Scanner scanner = new Scanner(System.in);

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

        int[] p = new int[N];

        for (int i = 0; i < N; i++) {
            p[i] = scanner.nextInt();
        }

        Arrays.sort(p);

        int ans = 0;

        for (int i = 0; i < K; i++) {
            ans += p[i];
        }

        System.out.println(ans);
    }
} Main public static void main(String[] var0) {
        Scanner scanner = new Scanner(System.in);

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

        int[] p = new int[N];

        for (int i = 0; i < N; i++) {
            p[i] = scanner.nextInt();
        }

        Arrays.sort(p);

        int ans = 0;

        for (int i = 0; i < K; i++) {
            ans += p[i];
        }

        System.out.println(ans);
    } main {
        Scanner scanner = new Scanner(System.in);

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

        int[] p = new int[N];

        for (int i = 0; i < N; i++) {
            p[i] = scanner.nextInt();
        }

        Arrays.sort(p);

        int ans = 0;

        for (int i = 0; i < K; i++) {
            ans += p[i];
        }

        System.out.println(ans);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int N = scanner.nextInt(); N scanner.nextInt() scanner.nextInt scanner int K = scanner.nextInt(); K scanner.nextInt() scanner.nextInt scanner int[] p = new int[N]; p new int[N] N for (int i = 0; i < N; i++) {
            p[i] = scanner.nextInt();
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            p[i] = scanner.nextInt();
        } {
            p[i] = scanner.nextInt();
        } p[i] = scanner.nextInt() p[i] p i scanner.nextInt() scanner.nextInt scanner Arrays.sort(p) Arrays.sort Arrays p int ans = 0; ans 0 for (int i = 0; i < K; i++) {
            ans += p[i];
        } int i = 0; int i = 0; i 0 i < K i K i++ i++ i {
            ans += p[i];
        } {
            ans += p[i];
        } ans += p[i] ans p[i] p i System.out.println(ans) System.out.println System.out System System.out ans String[] var0 var0 public class Main {
    public static void main(String[] var0) {
        Scanner scanner = new Scanner(System.in);

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

        int[] p = new int[N];

        for (int i = 0; i < N; i++) {
            p[i] = scanner.nextInt();
        }

        Arrays.sort(p);

        int ans = 0;

        for (int i = 0; i < K; i++) {
            ans += p[i];
        }

        System.out.println(ans);
    }
} public class Main {
    public static void main(String[] var0) {
        Scanner scanner = new Scanner(System.in);

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

        int[] p = new int[N];

        for (int i = 0; i < N; i++) {
            p[i] = scanner.nextInt();
        }

        Arrays.sort(p);

        int ans = 0;

        for (int i = 0; i < K; i++) {
            ans += p[i];
        }

        System.out.println(ans);
    }
} Main
import java.util.Arrays;
import java.util.Scanner;

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

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

        int[] p = new int[N];

        for (int i = 0; i < N; i++) {
            p[i] = scanner.nextInt();
        }

        Arrays.sort(p);

        int ans = 0;

        for (int i = 0; i < K; i++) {
            ans += p[i];
        }

        System.out.println(ans);
    }
}
