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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        List<Integer> prices = new ArrayList<Integer>();
        for(int i=0; i < n; i++){
            prices.add(sc.nextInt());
        }

        Integer total = 0;
        for(int i = 0; i < k; i++){
            Integer min = prices.get(0);
            for(int j = 1; j < prices.size(); j++){
                if(min > prices.get(j)){
                    min = prices.get(j);
                }
            }
            total += min;
            prices.remove(min);
        }
        System.out.println(total);
    }
} import java.util.ArrayList; ArrayList 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 sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        List<Integer> prices = new ArrayList<Integer>();
        for(int i=0; i < n; i++){
            prices.add(sc.nextInt());
        }

        Integer total = 0;
        for(int i = 0; i < k; i++){
            Integer min = prices.get(0);
            for(int j = 1; j < prices.size(); j++){
                if(min > prices.get(j)){
                    min = prices.get(j);
                }
            }
            total += min;
            prices.remove(min);
        }
        System.out.println(total);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        List<Integer> prices = new ArrayList<Integer>();
        for(int i=0; i < n; i++){
            prices.add(sc.nextInt());
        }

        Integer total = 0;
        for(int i = 0; i < k; i++){
            Integer min = prices.get(0);
            for(int j = 1; j < prices.size(); j++){
                if(min > prices.get(j)){
                    min = prices.get(j);
                }
            }
            total += min;
            prices.remove(min);
        }
        System.out.println(total);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        List<Integer> prices = new ArrayList<Integer>();
        for(int i=0; i < n; i++){
            prices.add(sc.nextInt());
        }

        Integer total = 0;
        for(int i = 0; i < k; i++){
            Integer min = prices.get(0);
            for(int j = 1; j < prices.size(); j++){
                if(min > prices.get(j)){
                    min = prices.get(j);
                }
            }
            total += min;
            prices.remove(min);
        }
        System.out.println(total);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int k = sc.nextInt(); k sc.nextInt() sc.nextInt sc List<Integer> prices = new ArrayList<Integer>(); prices new ArrayList<Integer>() for(int i=0; i < n; i++){
            prices.add(sc.nextInt());
        } int i=0; int i=0; i 0 i < n i n i++ i++ i {
            prices.add(sc.nextInt());
        } {
            prices.add(sc.nextInt());
        } prices.add(sc.nextInt()) prices.add prices sc.nextInt() sc.nextInt sc Integer total = 0; total 0 for(int i = 0; i < k; i++){
            Integer min = prices.get(0);
            for(int j = 1; j < prices.size(); j++){
                if(min > prices.get(j)){
                    min = prices.get(j);
                }
            }
            total += min;
            prices.remove(min);
        } int i = 0; int i = 0; i 0 i < k i k i++ i++ i {
            Integer min = prices.get(0);
            for(int j = 1; j < prices.size(); j++){
                if(min > prices.get(j)){
                    min = prices.get(j);
                }
            }
            total += min;
            prices.remove(min);
        } {
            Integer min = prices.get(0);
            for(int j = 1; j < prices.size(); j++){
                if(min > prices.get(j)){
                    min = prices.get(j);
                }
            }
            total += min;
            prices.remove(min);
        } Integer min = prices.get(0); min prices.get(0) prices.get prices 0 for(int j = 1; j < prices.size(); j++){
                if(min > prices.get(j)){
                    min = prices.get(j);
                }
            } int j = 1; int j = 1; j 1 j < prices.size() j prices.size() prices.size prices j++ j++ j {
                if(min > prices.get(j)){
                    min = prices.get(j);
                }
            } {
                if(min > prices.get(j)){
                    min = prices.get(j);
                }
            } if(min > prices.get(j)){
                    min = prices.get(j);
                } min > prices.get(j) min prices.get(j) prices.get prices j {
                    min = prices.get(j);
                } min = prices.get(j) min prices.get(j) prices.get prices j total += min total min prices.remove(min) prices.remove prices min System.out.println(total) System.out.println System.out System System.out total String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        List<Integer> prices = new ArrayList<Integer>();
        for(int i=0; i < n; i++){
            prices.add(sc.nextInt());
        }

        Integer total = 0;
        for(int i = 0; i < k; i++){
            Integer min = prices.get(0);
            for(int j = 1; j < prices.size(); j++){
                if(min > prices.get(j)){
                    min = prices.get(j);
                }
            }
            total += min;
            prices.remove(min);
        }
        System.out.println(total);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        List<Integer> prices = new ArrayList<Integer>();
        for(int i=0; i < n; i++){
            prices.add(sc.nextInt());
        }

        Integer total = 0;
        for(int i = 0; i < k; i++){
            Integer min = prices.get(0);
            for(int j = 1; j < prices.size(); j++){
                if(min > prices.get(j)){
                    min = prices.get(j);
                }
            }
            total += min;
            prices.remove(min);
        }
        System.out.println(total);
    }
} Main
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        List<Integer> prices = new ArrayList<Integer>();
        for(int i=0; i < n; i++){
            prices.add(sc.nextInt());
        }

        Integer total = 0;
        for(int i = 0; i < k; i++){
            Integer min = prices.get(0);
            for(int j = 1; j < prices.size(); j++){
                if(min > prices.get(j)){
                    min = prices.get(j);
                }
            }
            total += min;
            prices.remove(min);
        }
        System.out.println(total);
    }
}
