import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class Main {

    public static void main (String [] args) throws IOException {
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        //--------------------------START CODING HERE-----------------------------

        String  line= f.readLine();

        String[] theLine = line.split(" ");
        ArrayList<Integer> theInts = new ArrayList<>();

        StringTokenizer st = new StringTokenizer(f.readLine());
        for(int i = 0; i < Integer.parseInt(theLine[0]); i++)
        {

            theInts.add(Integer.parseInt(st.nextToken()));
        }
        Collections.sort(theInts);

        int sum = 0;
        for(int g = 0; g < Integer.parseInt(theLine[1]); g++)
        {
            sum+=theInts.get(g);
        }

        out.print(sum);


        out.close();
    }
} import java.io.*; io.* java import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util import java.util.StringTokenizer; StringTokenizer java.util public class Main {

    public static void main (String [] args) throws IOException {
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        //--------------------------START CODING HERE-----------------------------

        String  line= f.readLine();

        String[] theLine = line.split(" ");
        ArrayList<Integer> theInts = new ArrayList<>();

        StringTokenizer st = new StringTokenizer(f.readLine());
        for(int i = 0; i < Integer.parseInt(theLine[0]); i++)
        {

            theInts.add(Integer.parseInt(st.nextToken()));
        }
        Collections.sort(theInts);

        int sum = 0;
        for(int g = 0; g < Integer.parseInt(theLine[1]); g++)
        {
            sum+=theInts.get(g);
        }

        out.print(sum);


        out.close();
    }
} Main public static void main (String [] args) throws IOException {
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        //--------------------------START CODING HERE-----------------------------

        String  line= f.readLine();

        String[] theLine = line.split(" ");
        ArrayList<Integer> theInts = new ArrayList<>();

        StringTokenizer st = new StringTokenizer(f.readLine());
        for(int i = 0; i < Integer.parseInt(theLine[0]); i++)
        {

            theInts.add(Integer.parseInt(st.nextToken()));
        }
        Collections.sort(theInts);

        int sum = 0;
        for(int g = 0; g < Integer.parseInt(theLine[1]); g++)
        {
            sum+=theInts.get(g);
        }

        out.print(sum);


        out.close();
    } main {
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        //--------------------------START CODING HERE-----------------------------

        String  line= f.readLine();

        String[] theLine = line.split(" ");
        ArrayList<Integer> theInts = new ArrayList<>();

        StringTokenizer st = new StringTokenizer(f.readLine());
        for(int i = 0; i < Integer.parseInt(theLine[0]); i++)
        {

            theInts.add(Integer.parseInt(st.nextToken()));
        }
        Collections.sort(theInts);

        int sum = 0;
        for(int g = 0; g < Integer.parseInt(theLine[1]); g++)
        {
            sum+=theInts.get(g);
        }

        out.print(sum);


        out.close();
    } BufferedReader f = new BufferedReader(new InputStreamReader(System.in)); f new BufferedReader(new InputStreamReader(System.in)) PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) String  line= f.readLine(); line f.readLine() f.readLine f String[] theLine = line.split(" "); theLine line.split(" ") line.split line " " ArrayList<Integer> theInts = new ArrayList<>(); theInts new ArrayList<>() StringTokenizer st = new StringTokenizer(f.readLine()); st new StringTokenizer(f.readLine()) for(int i = 0; i < Integer.parseInt(theLine[0]); i++)
        {

            theInts.add(Integer.parseInt(st.nextToken()));
        } int i = 0; int i = 0; i 0 i < Integer.parseInt(theLine[0]) i Integer.parseInt(theLine[0]) Integer.parseInt Integer theLine[0] theLine 0 i++ i++ i {

            theInts.add(Integer.parseInt(st.nextToken()));
        } {

            theInts.add(Integer.parseInt(st.nextToken()));
        } theInts.add(Integer.parseInt(st.nextToken())) theInts.add theInts Integer.parseInt(st.nextToken()) Integer.parseInt Integer st.nextToken() st.nextToken st Collections.sort(theInts) Collections.sort Collections theInts int sum = 0; sum 0 for(int g = 0; g < Integer.parseInt(theLine[1]); g++)
        {
            sum+=theInts.get(g);
        } int g = 0; int g = 0; g 0 g < Integer.parseInt(theLine[1]) g Integer.parseInt(theLine[1]) Integer.parseInt Integer theLine[1] theLine 1 g++ g++ g {
            sum+=theInts.get(g);
        } {
            sum+=theInts.get(g);
        } sum+=theInts.get(g) sum theInts.get(g) theInts.get theInts g out.print(sum) out.print out sum out.close() out.close out String [] args args public class Main {

    public static void main (String [] args) throws IOException {
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        //--------------------------START CODING HERE-----------------------------

        String  line= f.readLine();

        String[] theLine = line.split(" ");
        ArrayList<Integer> theInts = new ArrayList<>();

        StringTokenizer st = new StringTokenizer(f.readLine());
        for(int i = 0; i < Integer.parseInt(theLine[0]); i++)
        {

            theInts.add(Integer.parseInt(st.nextToken()));
        }
        Collections.sort(theInts);

        int sum = 0;
        for(int g = 0; g < Integer.parseInt(theLine[1]); g++)
        {
            sum+=theInts.get(g);
        }

        out.print(sum);


        out.close();
    }
} public class Main {

    public static void main (String [] args) throws IOException {
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        //--------------------------START CODING HERE-----------------------------

        String  line= f.readLine();

        String[] theLine = line.split(" ");
        ArrayList<Integer> theInts = new ArrayList<>();

        StringTokenizer st = new StringTokenizer(f.readLine());
        for(int i = 0; i < Integer.parseInt(theLine[0]); i++)
        {

            theInts.add(Integer.parseInt(st.nextToken()));
        }
        Collections.sort(theInts);

        int sum = 0;
        for(int g = 0; g < Integer.parseInt(theLine[1]); g++)
        {
            sum+=theInts.get(g);
        }

        out.print(sum);


        out.close();
    }
} Main
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class Main {

    public static void main (String [] args) throws IOException {
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        //--------------------------START CODING HERE-----------------------------

        String  line= f.readLine();

        String[] theLine = line.split(" ");
        ArrayList<Integer> theInts = new ArrayList<>();

        StringTokenizer st = new StringTokenizer(f.readLine());
        for(int i = 0; i < Integer.parseInt(theLine[0]); i++)
        {

            theInts.add(Integer.parseInt(st.nextToken()));
        }
        Collections.sort(theInts);

        int sum = 0;
        for(int g = 0; g < Integer.parseInt(theLine[1]); g++)
        {
            sum+=theInts.get(g);
        }

        out.print(sum);


        out.close();
    }
}