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

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int K = scanner.nextInt();
        int sum = 0;
        List<Integer> prices = new ArrayList<Integer>();
        while (scanner.hasNext()){
          prices.add(scanner.nextInt());
        }
        prices.sort(Comparator.naturalOrder());
        for (int i = 0; i < K; i++) {
            sum += prices.get(i);
        }
        System.out.println(sum);



        scanner.close();
    }
} import java.util.ArrayList; ArrayList java.util import java.util.Comparator; Comparator 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 scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int K = scanner.nextInt();
        int sum = 0;
        List<Integer> prices = new ArrayList<Integer>();
        while (scanner.hasNext()){
          prices.add(scanner.nextInt());
        }
        prices.sort(Comparator.naturalOrder());
        for (int i = 0; i < K; i++) {
            sum += prices.get(i);
        }
        System.out.println(sum);



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



        scanner.close();
    } main {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int K = scanner.nextInt();
        int sum = 0;
        List<Integer> prices = new ArrayList<Integer>();
        while (scanner.hasNext()){
          prices.add(scanner.nextInt());
        }
        prices.sort(Comparator.naturalOrder());
        for (int i = 0; i < K; i++) {
            sum += prices.get(i);
        }
        System.out.println(sum);



        scanner.close();
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int N = scanner.nextInt(); N scanner.nextInt() scanner.nextInt scanner int K = scanner.nextInt(); K scanner.nextInt() scanner.nextInt scanner int sum = 0; sum 0 List<Integer> prices = new ArrayList<Integer>(); prices new ArrayList<Integer>() while (scanner.hasNext()){
          prices.add(scanner.nextInt());
        } scanner.hasNext() scanner.hasNext scanner {
          prices.add(scanner.nextInt());
        } prices.add(scanner.nextInt()) prices.add prices scanner.nextInt() scanner.nextInt scanner prices.sort(Comparator.naturalOrder()) prices.sort prices Comparator.naturalOrder() Comparator.naturalOrder Comparator for (int i = 0; i < K; i++) {
            sum += prices.get(i);
        } int i = 0; int i = 0; i 0 i < K i K i++ i++ i {
            sum += prices.get(i);
        } {
            sum += prices.get(i);
        } sum += prices.get(i) sum prices.get(i) prices.get prices i System.out.println(sum) System.out.println System.out System System.out sum scanner.close() scanner.close scanner String[] args args public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int K = scanner.nextInt();
        int sum = 0;
        List<Integer> prices = new ArrayList<Integer>();
        while (scanner.hasNext()){
          prices.add(scanner.nextInt());
        }
        prices.sort(Comparator.naturalOrder());
        for (int i = 0; i < K; i++) {
            sum += prices.get(i);
        }
        System.out.println(sum);



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

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int K = scanner.nextInt();
        int sum = 0;
        List<Integer> prices = new ArrayList<Integer>();
        while (scanner.hasNext()){
          prices.add(scanner.nextInt());
        }
        prices.sort(Comparator.naturalOrder());
        for (int i = 0; i < K; i++) {
            sum += prices.get(i);
        }
        System.out.println(sum);



        scanner.close();
    }
} Main
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int K = scanner.nextInt();
        int sum = 0;
        List<Integer> prices = new ArrayList<Integer>();
        while (scanner.hasNext()){
          prices.add(scanner.nextInt());
        }
        prices.sort(Comparator.naturalOrder());
        for (int i = 0; i < K; i++) {
            sum += prices.get(i);
        }
        System.out.println(sum);



        scanner.close();
    }
}
