import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.Collections;

public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

        String[] in = br.readLine().split(" ");
        int n = Integer.parseInt(in[0]);
        int k = Integer.parseInt(in[1]);
        in = br.readLine().split(" ");
        ArrayList<Integer> list = new ArrayList<>();
        for (String i : in) {
            list.add(Integer.parseInt(i));
        }

        br.close();

        Collections.sort(list);
        int ans = 0;
        for (int i = 0; i < k; i++) {
            ans += list.get(i);
        }

        bw.write(String.valueOf(ans));

        bw.flush();

    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.BufferedWriter; BufferedWriter java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.OutputStreamWriter; OutputStreamWriter java.io import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

        String[] in = br.readLine().split(" ");
        int n = Integer.parseInt(in[0]);
        int k = Integer.parseInt(in[1]);
        in = br.readLine().split(" ");
        ArrayList<Integer> list = new ArrayList<>();
        for (String i : in) {
            list.add(Integer.parseInt(i));
        }

        br.close();

        Collections.sort(list);
        int ans = 0;
        for (int i = 0; i < k; i++) {
            ans += list.get(i);
        }

        bw.write(String.valueOf(ans));

        bw.flush();

    }
} Main public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

        String[] in = br.readLine().split(" ");
        int n = Integer.parseInt(in[0]);
        int k = Integer.parseInt(in[1]);
        in = br.readLine().split(" ");
        ArrayList<Integer> list = new ArrayList<>();
        for (String i : in) {
            list.add(Integer.parseInt(i));
        }

        br.close();

        Collections.sort(list);
        int ans = 0;
        for (int i = 0; i < k; i++) {
            ans += list.get(i);
        }

        bw.write(String.valueOf(ans));

        bw.flush();

    } main {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

        String[] in = br.readLine().split(" ");
        int n = Integer.parseInt(in[0]);
        int k = Integer.parseInt(in[1]);
        in = br.readLine().split(" ");
        ArrayList<Integer> list = new ArrayList<>();
        for (String i : in) {
            list.add(Integer.parseInt(i));
        }

        br.close();

        Collections.sort(list);
        int ans = 0;
        for (int i = 0; i < k; i++) {
            ans += list.get(i);
        }

        bw.write(String.valueOf(ans));

        bw.flush();

    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); bw new BufferedWriter(new OutputStreamWriter(System.out)) String[] in = br.readLine().split(" "); in br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int n = Integer.parseInt(in[0]); n Integer.parseInt(in[0]) Integer.parseInt Integer in[0] in 0 int k = Integer.parseInt(in[1]); k Integer.parseInt(in[1]) Integer.parseInt Integer in[1] in 1 in = br.readLine().split(" ") in br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " ArrayList<Integer> list = new ArrayList<>(); list new ArrayList<>() for (String i : in) {
            list.add(Integer.parseInt(i));
        } String i in {
            list.add(Integer.parseInt(i));
        } {
            list.add(Integer.parseInt(i));
        } list.add(Integer.parseInt(i)) list.add list Integer.parseInt(i) Integer.parseInt Integer i br.close() br.close br Collections.sort(list) Collections.sort Collections list int ans = 0; ans 0 for (int i = 0; i < k; i++) {
            ans += list.get(i);
        } int i = 0; int i = 0; i 0 i < k i k i++ i++ i {
            ans += list.get(i);
        } {
            ans += list.get(i);
        } ans += list.get(i) ans list.get(i) list.get list i bw.write(String.valueOf(ans)) bw.write bw String.valueOf(ans) String.valueOf String ans bw.flush() bw.flush bw String[] args args public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

        String[] in = br.readLine().split(" ");
        int n = Integer.parseInt(in[0]);
        int k = Integer.parseInt(in[1]);
        in = br.readLine().split(" ");
        ArrayList<Integer> list = new ArrayList<>();
        for (String i : in) {
            list.add(Integer.parseInt(i));
        }

        br.close();

        Collections.sort(list);
        int ans = 0;
        for (int i = 0; i < k; i++) {
            ans += list.get(i);
        }

        bw.write(String.valueOf(ans));

        bw.flush();

    }
} public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

        String[] in = br.readLine().split(" ");
        int n = Integer.parseInt(in[0]);
        int k = Integer.parseInt(in[1]);
        in = br.readLine().split(" ");
        ArrayList<Integer> list = new ArrayList<>();
        for (String i : in) {
            list.add(Integer.parseInt(i));
        }

        br.close();

        Collections.sort(list);
        int ans = 0;
        for (int i = 0; i < k; i++) {
            ans += list.get(i);
        }

        bw.write(String.valueOf(ans));

        bw.flush();

    }
} Main
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.Collections;

public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

        String[] in = br.readLine().split(" ");
        int n = Integer.parseInt(in[0]);
        int k = Integer.parseInt(in[1]);
        in = br.readLine().split(" ");
        ArrayList<Integer> list = new ArrayList<>();
        for (String i : in) {
            list.add(Integer.parseInt(i));
        }

        br.close();

        Collections.sort(list);
        int ans = 0;
        for (int i = 0; i < k; i++) {
            ans += list.get(i);
        }

        bw.write(String.valueOf(ans));

        bw.flush();

    }
}