import java.lang.reflect.Array;
import java.math.BigInteger;
import java.nio.Buffer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
import java.util.Vector;

public class Main {
    public static Scanner r=new Scanner(System.in);
    public static void main(String[] args) {
        int n=r.nextInt();
        int k=r.nextInt();
        ArrayList<Integer> p=new ArrayList<>();
        for(int i=0;i<n;++i){
            int x=r.nextInt();
            p.add(x);
        }
        Collections.sort(p);
        int ans=0;
        for(int i=0;i<k;++i) ans+=p.get(i);
        System.out.println(ans);
    }
} import java.lang.reflect.Array; Array java.lang.reflect import java.math.BigInteger; BigInteger java.math import java.nio.Buffer; Buffer java.nio import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util import java.util.Scanner; Scanner java.util import java.util.Vector; Vector java.util public class Main {
    public static Scanner r=new Scanner(System.in);
    public static void main(String[] args) {
        int n=r.nextInt();
        int k=r.nextInt();
        ArrayList<Integer> p=new ArrayList<>();
        for(int i=0;i<n;++i){
            int x=r.nextInt();
            p.add(x);
        }
        Collections.sort(p);
        int ans=0;
        for(int i=0;i<k;++i) ans+=p.get(i);
        System.out.println(ans);
    }
} Main public static Scanner r=new Scanner(System.in); r new Scanner(System.in) public static void main(String[] args) {
        int n=r.nextInt();
        int k=r.nextInt();
        ArrayList<Integer> p=new ArrayList<>();
        for(int i=0;i<n;++i){
            int x=r.nextInt();
            p.add(x);
        }
        Collections.sort(p);
        int ans=0;
        for(int i=0;i<k;++i) ans+=p.get(i);
        System.out.println(ans);
    } main {
        int n=r.nextInt();
        int k=r.nextInt();
        ArrayList<Integer> p=new ArrayList<>();
        for(int i=0;i<n;++i){
            int x=r.nextInt();
            p.add(x);
        }
        Collections.sort(p);
        int ans=0;
        for(int i=0;i<k;++i) ans+=p.get(i);
        System.out.println(ans);
    } int n=r.nextInt(); n r.nextInt() r.nextInt r int k=r.nextInt(); k r.nextInt() r.nextInt r ArrayList<Integer> p=new ArrayList<>(); p new ArrayList<>() for(int i=0;i<n;++i){
            int x=r.nextInt();
            p.add(x);
        } int i=0; int i=0; i 0 i<n i n ++i ++i i {
            int x=r.nextInt();
            p.add(x);
        } {
            int x=r.nextInt();
            p.add(x);
        } int x=r.nextInt(); x r.nextInt() r.nextInt r p.add(x) p.add p x Collections.sort(p) Collections.sort Collections p int ans=0; ans 0 for(int i=0;i<k;++i) ans+=p.get(i); int i=0; int i=0; i 0 i<k i k ++i ++i i ans+=p.get(i); ans+=p.get(i) ans p.get(i) p.get p i System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
    public static Scanner r=new Scanner(System.in);
    public static void main(String[] args) {
        int n=r.nextInt();
        int k=r.nextInt();
        ArrayList<Integer> p=new ArrayList<>();
        for(int i=0;i<n;++i){
            int x=r.nextInt();
            p.add(x);
        }
        Collections.sort(p);
        int ans=0;
        for(int i=0;i<k;++i) ans+=p.get(i);
        System.out.println(ans);
    }
} public class Main {
    public static Scanner r=new Scanner(System.in);
    public static void main(String[] args) {
        int n=r.nextInt();
        int k=r.nextInt();
        ArrayList<Integer> p=new ArrayList<>();
        for(int i=0;i<n;++i){
            int x=r.nextInt();
            p.add(x);
        }
        Collections.sort(p);
        int ans=0;
        for(int i=0;i<k;++i) ans+=p.get(i);
        System.out.println(ans);
    }
} Main
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.nio.Buffer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
import java.util.Vector;

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