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

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

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