import java.util.Arrays;
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int ar[]=new int[n];
        int x=in.nextInt();
        for (int i = 0; i < n; i++) {
            ar[i]=in.nextInt();
        }
        Arrays.sort(ar);
        int sum=0,c=0;
        while(x-->0){
            sum=sum+ar[c];
            c++;
        }
        System.out.println(sum);
    }
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main{
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int ar[]=new int[n];
        int x=in.nextInt();
        for (int i = 0; i < n; i++) {
            ar[i]=in.nextInt();
        }
        Arrays.sort(ar);
        int sum=0,c=0;
        while(x-->0){
            sum=sum+ar[c];
            c++;
        }
        System.out.println(sum);
    }
} Main public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int ar[]=new int[n];
        int x=in.nextInt();
        for (int i = 0; i < n; i++) {
            ar[i]=in.nextInt();
        }
        Arrays.sort(ar);
        int sum=0,c=0;
        while(x-->0){
            sum=sum+ar[c];
            c++;
        }
        System.out.println(sum);
    } main {
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int ar[]=new int[n];
        int x=in.nextInt();
        for (int i = 0; i < n; i++) {
            ar[i]=in.nextInt();
        }
        Arrays.sort(ar);
        int sum=0,c=0;
        while(x-->0){
            sum=sum+ar[c];
            c++;
        }
        System.out.println(sum);
    } Scanner in=new Scanner(System.in); in new Scanner(System.in) int n=in.nextInt(); n in.nextInt() in.nextInt in int ar[]=new int[n]; ar new int[n] n int x=in.nextInt(); x in.nextInt() in.nextInt in for (int i = 0; i < n; i++) {
            ar[i]=in.nextInt();
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            ar[i]=in.nextInt();
        } {
            ar[i]=in.nextInt();
        } ar[i]=in.nextInt() ar[i] ar i in.nextInt() in.nextInt in Arrays.sort(ar) Arrays.sort Arrays ar int sum=0 sum 0 c=0; c 0 while(x-->0){
            sum=sum+ar[c];
            c++;
        } x-->0 x-- x 0 {
            sum=sum+ar[c];
            c++;
        } sum=sum+ar[c] sum sum+ar[c] sum ar[c] ar c c++ c 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) {
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int ar[]=new int[n];
        int x=in.nextInt();
        for (int i = 0; i < n; i++) {
            ar[i]=in.nextInt();
        }
        Arrays.sort(ar);
        int sum=0,c=0;
        while(x-->0){
            sum=sum+ar[c];
            c++;
        }
        System.out.println(sum);
    }
} public class Main{
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int ar[]=new int[n];
        int x=in.nextInt();
        for (int i = 0; i < n; i++) {
            ar[i]=in.nextInt();
        }
        Arrays.sort(ar);
        int sum=0,c=0;
        while(x-->0){
            sum=sum+ar[c];
            c++;
        }
        System.out.println(sum);
    }
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int ar[]=new int[n];
        int x=in.nextInt();
        for (int i = 0; i < n; i++) {
            ar[i]=in.nextInt();
        }
        Arrays.sort(ar);
        int sum=0,c=0;
        while(x-->0){
            sum=sum+ar[c];
            c++;
        }
        System.out.println(sum);
    }
}