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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());

        List<Integer> list = new ArrayList<>();
        for(int i=0; i<n; i++){
            list.add(Integer.parseInt(sc.next()));
        }
        Collections.sort(list);
        int total = 0;
        for(int i=0; i<k; i++){
            total += list.get(i);
        }
        System.out.println(total);
    }
} import java.util.List; List java.util import java.util.Scanner; Scanner java.util import java.util.Collections; Collections java.util import java.util.ArrayList; ArrayList java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());

        List<Integer> list = new ArrayList<>();
        for(int i=0; i<n; i++){
            list.add(Integer.parseInt(sc.next()));
        }
        Collections.sort(list);
        int total = 0;
        for(int i=0; i<k; i++){
            total += list.get(i);
        }
        System.out.println(total);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());

        List<Integer> list = new ArrayList<>();
        for(int i=0; i<n; i++){
            list.add(Integer.parseInt(sc.next()));
        }
        Collections.sort(list);
        int total = 0;
        for(int i=0; i<k; i++){
            total += list.get(i);
        }
        System.out.println(total);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());

        List<Integer> list = new ArrayList<>();
        for(int i=0; i<n; i++){
            list.add(Integer.parseInt(sc.next()));
        }
        Collections.sort(list);
        int total = 0;
        for(int i=0; i<k; i++){
            total += list.get(i);
        }
        System.out.println(total);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = Integer.parseInt(sc.next()); n Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int k = Integer.parseInt(sc.next()); k Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc List<Integer> list = new ArrayList<>(); list new ArrayList<>() for(int i=0; i<n; i++){
            list.add(Integer.parseInt(sc.next()));
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
            list.add(Integer.parseInt(sc.next()));
        } {
            list.add(Integer.parseInt(sc.next()));
        } list.add(Integer.parseInt(sc.next())) list.add list Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc Collections.sort(list) Collections.sort Collections list int total = 0; total 0 for(int i=0; i<k; i++){
            total += list.get(i);
        } int i=0; int i=0; i 0 i<k i k i++ i++ i {
            total += list.get(i);
        } {
            total += list.get(i);
        } total += list.get(i) total list.get(i) list.get list i 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 = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());

        List<Integer> list = new ArrayList<>();
        for(int i=0; i<n; i++){
            list.add(Integer.parseInt(sc.next()));
        }
        Collections.sort(list);
        int total = 0;
        for(int i=0; i<k; i++){
            total += list.get(i);
        }
        System.out.println(total);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());

        List<Integer> list = new ArrayList<>();
        for(int i=0; i<n; i++){
            list.add(Integer.parseInt(sc.next()));
        }
        Collections.sort(list);
        int total = 0;
        for(int i=0; i<k; i++){
            total += list.get(i);
        }
        System.out.println(total);
    }
} Main
import java.util.List;
import java.util.Scanner;
import java.util.Collections;
import java.util.ArrayList;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());

        List<Integer> list = new ArrayList<>();
        for(int i=0; i<n; i++){
            list.add(Integer.parseInt(sc.next()));
        }
        Collections.sort(list);
        int total = 0;
        for(int i=0; i<k; i++){
            total += list.get(i);
        }
        System.out.println(total);
    }
}