import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int K = scan.nextInt();

        List<Integer> listN = new ArrayList<Integer>();

        for(int i = 0; i < N; i++){
            listN.add(scan.nextInt());
        }

        Collections.sort(listN);

        int sum = 0;

        for(int i = 0; i < K; i++){
            sum = sum + listN.get(i);
        }

        System.out.println(sum);

        scan.close();
    }
} import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int K = scan.nextInt();

        List<Integer> listN = new ArrayList<Integer>();

        for(int i = 0; i < N; i++){
            listN.add(scan.nextInt());
        }

        Collections.sort(listN);

        int sum = 0;

        for(int i = 0; i < K; i++){
            sum = sum + listN.get(i);
        }

        System.out.println(sum);

        scan.close();
    }
} Main public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int K = scan.nextInt();

        List<Integer> listN = new ArrayList<Integer>();

        for(int i = 0; i < N; i++){
            listN.add(scan.nextInt());
        }

        Collections.sort(listN);

        int sum = 0;

        for(int i = 0; i < K; i++){
            sum = sum + listN.get(i);
        }

        System.out.println(sum);

        scan.close();
    } main {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int K = scan.nextInt();

        List<Integer> listN = new ArrayList<Integer>();

        for(int i = 0; i < N; i++){
            listN.add(scan.nextInt());
        }

        Collections.sort(listN);

        int sum = 0;

        for(int i = 0; i < K; i++){
            sum = sum + listN.get(i);
        }

        System.out.println(sum);

        scan.close();
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int N = scan.nextInt(); N scan.nextInt() scan.nextInt scan int K = scan.nextInt(); K scan.nextInt() scan.nextInt scan List<Integer> listN = new ArrayList<Integer>(); listN new ArrayList<Integer>() for(int i = 0; i < N; i++){
            listN.add(scan.nextInt());
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            listN.add(scan.nextInt());
        } {
            listN.add(scan.nextInt());
        } listN.add(scan.nextInt()) listN.add listN scan.nextInt() scan.nextInt scan Collections.sort(listN) Collections.sort Collections listN int sum = 0; sum 0 for(int i = 0; i < K; i++){
            sum = sum + listN.get(i);
        } int i = 0; int i = 0; i 0 i < K i K i++ i++ i {
            sum = sum + listN.get(i);
        } {
            sum = sum + listN.get(i);
        } sum = sum + listN.get(i) sum sum + listN.get(i) sum listN.get(i) listN.get listN i System.out.println(sum) System.out.println System.out System System.out sum scan.close() scan.close scan String[] args args public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int K = scan.nextInt();

        List<Integer> listN = new ArrayList<Integer>();

        for(int i = 0; i < N; i++){
            listN.add(scan.nextInt());
        }

        Collections.sort(listN);

        int sum = 0;

        for(int i = 0; i < K; i++){
            sum = sum + listN.get(i);
        }

        System.out.println(sum);

        scan.close();
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int K = scan.nextInt();

        List<Integer> listN = new ArrayList<Integer>();

        for(int i = 0; i < N; i++){
            listN.add(scan.nextInt());
        }

        Collections.sort(listN);

        int sum = 0;

        for(int i = 0; i < K; i++){
            sum = sum + listN.get(i);
        }

        System.out.println(sum);

        scan.close();
    }
} Main
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int K = scan.nextInt();

        List<Integer> listN = new ArrayList<Integer>();

        for(int i = 0; i < N; i++){
            listN.add(scan.nextInt());
        }

        Collections.sort(listN);

        int sum = 0;

        for(int i = 0; i < K; i++){
            sum = sum + listN.get(i);
        }

        System.out.println(sum);

        scan.close();
    }
}