import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        String [] inp = buffer.readLine().split(" ");
        int n = Integer.parseInt(inp[0]), k = Integer.parseInt(inp[1]);
        inp = buffer.readLine().split(" ");
        int [] prices = new int[n];
        for (int pos = 0; pos < n; pos++)
            prices[pos] = Integer.parseInt(inp[pos]);
        Arrays.sort(prices);
        int sum = 0;
        for (int pos = 0; pos < k; pos++) {
            sum += prices[pos];
        }
        sb.append(sum);
        System.out.println(sb);
    }
} import java.io.*; io.* java import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        String [] inp = buffer.readLine().split(" ");
        int n = Integer.parseInt(inp[0]), k = Integer.parseInt(inp[1]);
        inp = buffer.readLine().split(" ");
        int [] prices = new int[n];
        for (int pos = 0; pos < n; pos++)
            prices[pos] = Integer.parseInt(inp[pos]);
        Arrays.sort(prices);
        int sum = 0;
        for (int pos = 0; pos < k; pos++) {
            sum += prices[pos];
        }
        sb.append(sum);
        System.out.println(sb);
    }
} Main public static void main(String[] args) throws Exception {
        BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        String [] inp = buffer.readLine().split(" ");
        int n = Integer.parseInt(inp[0]), k = Integer.parseInt(inp[1]);
        inp = buffer.readLine().split(" ");
        int [] prices = new int[n];
        for (int pos = 0; pos < n; pos++)
            prices[pos] = Integer.parseInt(inp[pos]);
        Arrays.sort(prices);
        int sum = 0;
        for (int pos = 0; pos < k; pos++) {
            sum += prices[pos];
        }
        sb.append(sum);
        System.out.println(sb);
    } main {
        BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        String [] inp = buffer.readLine().split(" ");
        int n = Integer.parseInt(inp[0]), k = Integer.parseInt(inp[1]);
        inp = buffer.readLine().split(" ");
        int [] prices = new int[n];
        for (int pos = 0; pos < n; pos++)
            prices[pos] = Integer.parseInt(inp[pos]);
        Arrays.sort(prices);
        int sum = 0;
        for (int pos = 0; pos < k; pos++) {
            sum += prices[pos];
        }
        sb.append(sum);
        System.out.println(sb);
    } BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in)); buffer new BufferedReader(new InputStreamReader(System.in)) StringBuilder sb = new StringBuilder(); sb new StringBuilder() String [] inp = buffer.readLine().split(" "); inp buffer.readLine().split(" ") buffer.readLine().split buffer.readLine() buffer.readLine buffer " " int n = Integer.parseInt(inp[0]) n Integer.parseInt(inp[0]) Integer.parseInt Integer inp[0] inp 0 k = Integer.parseInt(inp[1]); k Integer.parseInt(inp[1]) Integer.parseInt Integer inp[1] inp 1 inp = buffer.readLine().split(" ") inp buffer.readLine().split(" ") buffer.readLine().split buffer.readLine() buffer.readLine buffer " " int [] prices = new int[n]; prices new int[n] n for (int pos = 0; pos < n; pos++)
            prices[pos] = Integer.parseInt(inp[pos]); int pos = 0; int pos = 0; pos 0 pos < n pos n pos++ pos++ pos prices[pos] = Integer.parseInt(inp[pos]); prices[pos] = Integer.parseInt(inp[pos]) prices[pos] prices pos Integer.parseInt(inp[pos]) Integer.parseInt Integer inp[pos] inp pos Arrays.sort(prices) Arrays.sort Arrays prices int sum = 0; sum 0 for (int pos = 0; pos < k; pos++) {
            sum += prices[pos];
        } int pos = 0; int pos = 0; pos 0 pos < k pos k pos++ pos++ pos {
            sum += prices[pos];
        } {
            sum += prices[pos];
        } sum += prices[pos] sum prices[pos] prices pos sb.append(sum) sb.append sb sum System.out.println(sb) System.out.println System.out System System.out sb String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        String [] inp = buffer.readLine().split(" ");
        int n = Integer.parseInt(inp[0]), k = Integer.parseInt(inp[1]);
        inp = buffer.readLine().split(" ");
        int [] prices = new int[n];
        for (int pos = 0; pos < n; pos++)
            prices[pos] = Integer.parseInt(inp[pos]);
        Arrays.sort(prices);
        int sum = 0;
        for (int pos = 0; pos < k; pos++) {
            sum += prices[pos];
        }
        sb.append(sum);
        System.out.println(sb);
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        String [] inp = buffer.readLine().split(" ");
        int n = Integer.parseInt(inp[0]), k = Integer.parseInt(inp[1]);
        inp = buffer.readLine().split(" ");
        int [] prices = new int[n];
        for (int pos = 0; pos < n; pos++)
            prices[pos] = Integer.parseInt(inp[pos]);
        Arrays.sort(prices);
        int sum = 0;
        for (int pos = 0; pos < k; pos++) {
            sum += prices[pos];
        }
        sb.append(sum);
        System.out.println(sb);
    }
} Main
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        String [] inp = buffer.readLine().split(" ");
        int n = Integer.parseInt(inp[0]), k = Integer.parseInt(inp[1]);
        inp = buffer.readLine().split(" ");
        int [] prices = new int[n];
        for (int pos = 0; pos < n; pos++)
            prices[pos] = Integer.parseInt(inp[pos]);
        Arrays.sort(prices);
        int sum = 0;
        for (int pos = 0; pos < k; pos++) {
            sum += prices[pos];
        }
        sb.append(sum);
        System.out.println(sb);
    }
}
