import 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> kudamono = new ArrayList<>();
        for (int i=1;i<=n;i++) {
            kudamono.add(sc.nextInt());
        }

        int ans=0;
        Collections.sort(kudamono);
        for (int i=0;i<k;i++) {
            ans += kudamono.get(i);
        }
        System.out.println(ans);
    }
} import java.util.*; util.* java 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> kudamono = new ArrayList<>();
        for (int i=1;i<=n;i++) {
            kudamono.add(sc.nextInt());
        }

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

        int ans=0;
        Collections.sort(kudamono);
        for (int i=0;i<k;i++) {
            ans += kudamono.get(i);
        }
        System.out.println(ans);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        List<Integer> kudamono = new ArrayList<>();
        for (int i=1;i<=n;i++) {
            kudamono.add(sc.nextInt());
        }

        int ans=0;
        Collections.sort(kudamono);
        for (int i=0;i<k;i++) {
            ans += kudamono.get(i);
        }
        System.out.println(ans);
    } 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> kudamono = new ArrayList<>(); kudamono new ArrayList<>() for (int i=1;i<=n;i++) {
            kudamono.add(sc.nextInt());
        } int i=1; int i=1; i 1 i<=n i n i++ i++ i {
            kudamono.add(sc.nextInt());
        } {
            kudamono.add(sc.nextInt());
        } kudamono.add(sc.nextInt()) kudamono.add kudamono sc.nextInt() sc.nextInt sc int ans=0; ans 0 Collections.sort(kudamono) Collections.sort Collections kudamono for (int i=0;i<k;i++) {
            ans += kudamono.get(i);
        } int i=0; int i=0; i 0 i<k i k i++ i++ i {
            ans += kudamono.get(i);
        } {
            ans += kudamono.get(i);
        } ans += kudamono.get(i) ans kudamono.get(i) kudamono.get kudamono i System.out.println(ans) System.out.println System.out System System.out ans 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> kudamono = new ArrayList<>();
        for (int i=1;i<=n;i++) {
            kudamono.add(sc.nextInt());
        }

        int ans=0;
        Collections.sort(kudamono);
        for (int i=0;i<k;i++) {
            ans += kudamono.get(i);
        }
        System.out.println(ans);
    }
} 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> kudamono = new ArrayList<>();
        for (int i=1;i<=n;i++) {
            kudamono.add(sc.nextInt());
        }

        int ans=0;
        Collections.sort(kudamono);
        for (int i=0;i<k;i++) {
            ans += kudamono.get(i);
        }
        System.out.println(ans);
    }
} Main
import 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> kudamono = new ArrayList<>();
        for (int i=1;i<=n;i++) {
            kudamono.add(sc.nextInt());
        }

        int ans=0;
        Collections.sort(kudamono);
        for (int i=0;i<k;i++) {
            ans += kudamono.get(i);
        }
        System.out.println(ans);
    }
}
