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

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int k, n;
        n = sc.nextInt();
        k = sc.nextInt();
        int i = 0;
        List<Integer> list = new ArrayList<>();
        while(i < n){
            list.add(sc.nextInt());
            i++;
        }
        sc.close();
        Collections.sort(list);
        i = 0;
        int sum = 0;
        while(i < k){
            sum += list.get(i);
            i++;
        }
        System.out.println(sum);
    }
} import java.util.Scanner; Scanner java.util import java.util.ArrayList; ArrayList java.util import java.util.List; List java.util import java.util.Collections; Collections java.util public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int k, n;
        n = sc.nextInt();
        k = sc.nextInt();
        int i = 0;
        List<Integer> list = new ArrayList<>();
        while(i < n){
            list.add(sc.nextInt());
            i++;
        }
        sc.close();
        Collections.sort(list);
        i = 0;
        int sum = 0;
        while(i < k){
            sum += list.get(i);
            i++;
        }
        System.out.println(sum);
    }
} Main public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int k, n;
        n = sc.nextInt();
        k = sc.nextInt();
        int i = 0;
        List<Integer> list = new ArrayList<>();
        while(i < n){
            list.add(sc.nextInt());
            i++;
        }
        sc.close();
        Collections.sort(list);
        i = 0;
        int sum = 0;
        while(i < k){
            sum += list.get(i);
            i++;
        }
        System.out.println(sum);
    } main {
        Scanner sc = new Scanner(System.in);
        int k, n;
        n = sc.nextInt();
        k = sc.nextInt();
        int i = 0;
        List<Integer> list = new ArrayList<>();
        while(i < n){
            list.add(sc.nextInt());
            i++;
        }
        sc.close();
        Collections.sort(list);
        i = 0;
        int sum = 0;
        while(i < k){
            sum += list.get(i);
            i++;
        }
        System.out.println(sum);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int k k n; n n = sc.nextInt() n sc.nextInt() sc.nextInt sc k = sc.nextInt() k sc.nextInt() sc.nextInt sc int i = 0; i 0 List<Integer> list = new ArrayList<>(); list new ArrayList<>() while(i < n){
            list.add(sc.nextInt());
            i++;
        } i < n i n {
            list.add(sc.nextInt());
            i++;
        } list.add(sc.nextInt()) list.add list sc.nextInt() sc.nextInt sc i++ i sc.close() sc.close sc Collections.sort(list) Collections.sort Collections list i = 0 i 0 int sum = 0; sum 0 while(i < k){
            sum += list.get(i);
            i++;
        } i < k i k {
            sum += list.get(i);
            i++;
        } sum += list.get(i) sum list.get(i) list.get list i i++ i System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int k, n;
        n = sc.nextInt();
        k = sc.nextInt();
        int i = 0;
        List<Integer> list = new ArrayList<>();
        while(i < n){
            list.add(sc.nextInt());
            i++;
        }
        sc.close();
        Collections.sort(list);
        i = 0;
        int sum = 0;
        while(i < k){
            sum += list.get(i);
            i++;
        }
        System.out.println(sum);
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int k, n;
        n = sc.nextInt();
        k = sc.nextInt();
        int i = 0;
        List<Integer> list = new ArrayList<>();
        while(i < n){
            list.add(sc.nextInt());
            i++;
        }
        sc.close();
        Collections.sort(list);
        i = 0;
        int sum = 0;
        while(i < k){
            sum += list.get(i);
            i++;
        }
        System.out.println(sum);
    }
} Main
import java.util.Scanner;
import java.util.ArrayList;
import java.util.List;
import java.util.Collections;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int k, n;
        n = sc.nextInt();
        k = sc.nextInt();
        int i = 0;
        List<Integer> list = new ArrayList<>();
        while(i < n){
            list.add(sc.nextInt());
            i++;
        }
        sc.close();
        Collections.sort(list);
        i = 0;
        int sum = 0;
        while(i < k){
            sum += list.get(i);
            i++;
        }
        System.out.println(sum);
    }
}
