import java.io.*;
import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayList;
import java.math.BigDecimal;

public class Main{

    public static void main(String[] args){
        //START

        Scanner sc=new Scanner(System.in);

        //String N=sc.next();

        int N=sc.nextInt();
        int K=sc.nextInt();

        int[] p=new int[N];

        int i=0;

        for(i=0;i<N;i++){
            p[i]=sc.nextInt();
            //System.out.println(p[i]+" ");
        }

        Arrays.sort(p);

        int sum=0;

        for(i=0;i<K;i++){
            sum=sum+p[i];
            //System.out.println(p[i]);
        }

        System.out.print(sum);
        //END
    }
}



 import java.io.*; io.* java import java.util.Scanner; Scanner java.util import java.util.Arrays; Arrays java.util import java.util.ArrayList; ArrayList java.util import java.math.BigDecimal; BigDecimal java.math public class Main{

    public static void main(String[] args){
        //START

        Scanner sc=new Scanner(System.in);

        //String N=sc.next();

        int N=sc.nextInt();
        int K=sc.nextInt();

        int[] p=new int[N];

        int i=0;

        for(i=0;i<N;i++){
            p[i]=sc.nextInt();
            //System.out.println(p[i]+" ");
        }

        Arrays.sort(p);

        int sum=0;

        for(i=0;i<K;i++){
            sum=sum+p[i];
            //System.out.println(p[i]);
        }

        System.out.print(sum);
        //END
    }
} Main public static void main(String[] args){
        //START

        Scanner sc=new Scanner(System.in);

        //String N=sc.next();

        int N=sc.nextInt();
        int K=sc.nextInt();

        int[] p=new int[N];

        int i=0;

        for(i=0;i<N;i++){
            p[i]=sc.nextInt();
            //System.out.println(p[i]+" ");
        }

        Arrays.sort(p);

        int sum=0;

        for(i=0;i<K;i++){
            sum=sum+p[i];
            //System.out.println(p[i]);
        }

        System.out.print(sum);
        //END
    } main {
        //START

        Scanner sc=new Scanner(System.in);

        //String N=sc.next();

        int N=sc.nextInt();
        int K=sc.nextInt();

        int[] p=new int[N];

        int i=0;

        for(i=0;i<N;i++){
            p[i]=sc.nextInt();
            //System.out.println(p[i]+" ");
        }

        Arrays.sort(p);

        int sum=0;

        for(i=0;i<K;i++){
            sum=sum+p[i];
            //System.out.println(p[i]);
        }

        System.out.print(sum);
        //END
    } 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 int[] p=new int[N]; p new int[N] N int i=0; i 0 for(i=0;i<N;i++){
            p[i]=sc.nextInt();
            //System.out.println(p[i]+" ");
        } i=0; i=0 i 0 i<N i N i++ i++ i {
            p[i]=sc.nextInt();
            //System.out.println(p[i]+" ");
        } {
            p[i]=sc.nextInt();
            //System.out.println(p[i]+" ");
        } p[i]=sc.nextInt() p[i] p i sc.nextInt() sc.nextInt sc Arrays.sort(p) Arrays.sort Arrays p int sum=0; sum 0 for(i=0;i<K;i++){
            sum=sum+p[i];
            //System.out.println(p[i]);
        } i=0; i=0 i 0 i<K i K i++ i++ i {
            sum=sum+p[i];
            //System.out.println(p[i]);
        } {
            sum=sum+p[i];
            //System.out.println(p[i]);
        } sum=sum+p[i] sum sum+p[i] sum p[i] p i System.out.print(sum) System.out.print System.out System System.out sum String[] args args public class Main{

    public static void main(String[] args){
        //START

        Scanner sc=new Scanner(System.in);

        //String N=sc.next();

        int N=sc.nextInt();
        int K=sc.nextInt();

        int[] p=new int[N];

        int i=0;

        for(i=0;i<N;i++){
            p[i]=sc.nextInt();
            //System.out.println(p[i]+" ");
        }

        Arrays.sort(p);

        int sum=0;

        for(i=0;i<K;i++){
            sum=sum+p[i];
            //System.out.println(p[i]);
        }

        System.out.print(sum);
        //END
    }
} public class Main{

    public static void main(String[] args){
        //START

        Scanner sc=new Scanner(System.in);

        //String N=sc.next();

        int N=sc.nextInt();
        int K=sc.nextInt();

        int[] p=new int[N];

        int i=0;

        for(i=0;i<N;i++){
            p[i]=sc.nextInt();
            //System.out.println(p[i]+" ");
        }

        Arrays.sort(p);

        int sum=0;

        for(i=0;i<K;i++){
            sum=sum+p[i];
            //System.out.println(p[i]);
        }

        System.out.print(sum);
        //END
    }
} Main
import java.io.*;
import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayList;
import java.math.BigDecimal;

public class Main{

    public static void main(String[] args){
        //START

        Scanner sc=new Scanner(System.in);

        //String N=sc.next();

        int N=sc.nextInt();
        int K=sc.nextInt();

        int[] p=new int[N];

        int i=0;

        for(i=0;i<N;i++){
            p[i]=sc.nextInt();
            //System.out.println(p[i]+" ");
        }

        Arrays.sort(p);

        int sum=0;

        for(i=0;i<K;i++){
            sum=sum+p[i];
            //System.out.println(p[i]);
        }

        System.out.print(sum);
        //END
    }
}




