import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int K = Integer.parseInt(sc.next());
        int p[] = new int[N];
        int kakaku = 0;

        for (int i = 0; i < N; i++) {
            p[i] = Integer.parseInt(sc.next());
        }

        Arrays.sort(p);

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

        PrintWriter out = new PrintWriter(System.out);
        out.println(kakaku);

        sc.close();
        out.flush();
    }
} import java.io.PrintWriter; PrintWriter java.io import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int K = Integer.parseInt(sc.next());
        int p[] = new int[N];
        int kakaku = 0;

        for (int i = 0; i < N; i++) {
            p[i] = Integer.parseInt(sc.next());
        }

        Arrays.sort(p);

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

        PrintWriter out = new PrintWriter(System.out);
        out.println(kakaku);

        sc.close();
        out.flush();
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int K = Integer.parseInt(sc.next());
        int p[] = new int[N];
        int kakaku = 0;

        for (int i = 0; i < N; i++) {
            p[i] = Integer.parseInt(sc.next());
        }

        Arrays.sort(p);

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

        PrintWriter out = new PrintWriter(System.out);
        out.println(kakaku);

        sc.close();
        out.flush();
    } main {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int K = Integer.parseInt(sc.next());
        int p[] = new int[N];
        int kakaku = 0;

        for (int i = 0; i < N; i++) {
            p[i] = Integer.parseInt(sc.next());
        }

        Arrays.sort(p);

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

        PrintWriter out = new PrintWriter(System.out);
        out.println(kakaku);

        sc.close();
        out.flush();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = Integer.parseInt(sc.next()); N Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int K = Integer.parseInt(sc.next()); K Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int p[] = new int[N]; p new int[N] N int kakaku = 0; kakaku 0 for (int i = 0; i < N; i++) {
            p[i] = Integer.parseInt(sc.next());
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            p[i] = Integer.parseInt(sc.next());
        } {
            p[i] = Integer.parseInt(sc.next());
        } p[i] = Integer.parseInt(sc.next()) p[i] p i Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc Arrays.sort(p) Arrays.sort Arrays p for (int i = 0; i < K; i++) {
            kakaku += p[i];
        } int i = 0; int i = 0; i 0 i < K i K i++ i++ i {
            kakaku += p[i];
        } {
            kakaku += p[i];
        } kakaku += p[i] kakaku p[i] p i PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) out.println(kakaku) out.println out kakaku sc.close() sc.close sc out.flush() out.flush out String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int K = Integer.parseInt(sc.next());
        int p[] = new int[N];
        int kakaku = 0;

        for (int i = 0; i < N; i++) {
            p[i] = Integer.parseInt(sc.next());
        }

        Arrays.sort(p);

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

        PrintWriter out = new PrintWriter(System.out);
        out.println(kakaku);

        sc.close();
        out.flush();
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int K = Integer.parseInt(sc.next());
        int p[] = new int[N];
        int kakaku = 0;

        for (int i = 0; i < N; i++) {
            p[i] = Integer.parseInt(sc.next());
        }

        Arrays.sort(p);

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

        PrintWriter out = new PrintWriter(System.out);
        out.println(kakaku);

        sc.close();
        out.flush();
    }
} Main
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int K = Integer.parseInt(sc.next());
        int p[] = new int[N];
        int kakaku = 0;

        for (int i = 0; i < N; i++) {
            p[i] = Integer.parseInt(sc.next());
        }

        Arrays.sort(p);

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

        PrintWriter out = new PrintWriter(System.out);
        out.println(kakaku);

        sc.close();
        out.flush();
    }
}