import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String ars[])throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw=new PrintWriter(System.out);
        String str[]=br.readLine().split(" ");
        int n=Integer.parseInt(str[0]);
        int k=Integer.parseInt(str[1]);
        str=br.readLine().split(" ");
        int arr[]=new int[n];
        for(int i=0;i<n;i++)
        arr[i]=Integer.parseInt(str[i]);
        Arrays.sort(arr);
        int sum=0;
        for(int i=0;i<k;i++)
        sum+=arr[i];
        pw.println(sum);
        pw.flush();
        pw.close();
    }
} import java.util.*; util.* java import java.io.*; io.* java public class Main
{
    public static void main(String ars[])throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw=new PrintWriter(System.out);
        String str[]=br.readLine().split(" ");
        int n=Integer.parseInt(str[0]);
        int k=Integer.parseInt(str[1]);
        str=br.readLine().split(" ");
        int arr[]=new int[n];
        for(int i=0;i<n;i++)
        arr[i]=Integer.parseInt(str[i]);
        Arrays.sort(arr);
        int sum=0;
        for(int i=0;i<k;i++)
        sum+=arr[i];
        pw.println(sum);
        pw.flush();
        pw.close();
    }
} Main public static void main(String ars[])throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw=new PrintWriter(System.out);
        String str[]=br.readLine().split(" ");
        int n=Integer.parseInt(str[0]);
        int k=Integer.parseInt(str[1]);
        str=br.readLine().split(" ");
        int arr[]=new int[n];
        for(int i=0;i<n;i++)
        arr[i]=Integer.parseInt(str[i]);
        Arrays.sort(arr);
        int sum=0;
        for(int i=0;i<k;i++)
        sum+=arr[i];
        pw.println(sum);
        pw.flush();
        pw.close();
    } main {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw=new PrintWriter(System.out);
        String str[]=br.readLine().split(" ");
        int n=Integer.parseInt(str[0]);
        int k=Integer.parseInt(str[1]);
        str=br.readLine().split(" ");
        int arr[]=new int[n];
        for(int i=0;i<n;i++)
        arr[i]=Integer.parseInt(str[i]);
        Arrays.sort(arr);
        int sum=0;
        for(int i=0;i<k;i++)
        sum+=arr[i];
        pw.println(sum);
        pw.flush();
        pw.close();
    } BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) PrintWriter pw=new PrintWriter(System.out); pw new PrintWriter(System.out) String str[]=br.readLine().split(" "); str br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int n=Integer.parseInt(str[0]); n Integer.parseInt(str[0]) Integer.parseInt Integer str[0] str 0 int k=Integer.parseInt(str[1]); k Integer.parseInt(str[1]) Integer.parseInt Integer str[1] str 1 str=br.readLine().split(" ") str br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int arr[]=new int[n]; arr new int[n] n for(int i=0;i<n;i++)
        arr[i]=Integer.parseInt(str[i]); int i=0; int i=0; i 0 i<n i n i++ i++ i arr[i]=Integer.parseInt(str[i]); arr[i]=Integer.parseInt(str[i]) arr[i] arr i Integer.parseInt(str[i]) Integer.parseInt Integer str[i] str i Arrays.sort(arr) Arrays.sort Arrays arr int sum=0; sum 0 for(int i=0;i<k;i++)
        sum+=arr[i]; int i=0; int i=0; i 0 i<k i k i++ i++ i sum+=arr[i]; sum+=arr[i] sum arr[i] arr i pw.println(sum) pw.println pw sum pw.flush() pw.flush pw pw.close() pw.close pw String ars[] ars public class Main
{
    public static void main(String ars[])throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw=new PrintWriter(System.out);
        String str[]=br.readLine().split(" ");
        int n=Integer.parseInt(str[0]);
        int k=Integer.parseInt(str[1]);
        str=br.readLine().split(" ");
        int arr[]=new int[n];
        for(int i=0;i<n;i++)
        arr[i]=Integer.parseInt(str[i]);
        Arrays.sort(arr);
        int sum=0;
        for(int i=0;i<k;i++)
        sum+=arr[i];
        pw.println(sum);
        pw.flush();
        pw.close();
    }
} public class Main
{
    public static void main(String ars[])throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw=new PrintWriter(System.out);
        String str[]=br.readLine().split(" ");
        int n=Integer.parseInt(str[0]);
        int k=Integer.parseInt(str[1]);
        str=br.readLine().split(" ");
        int arr[]=new int[n];
        for(int i=0;i<n;i++)
        arr[i]=Integer.parseInt(str[i]);
        Arrays.sort(arr);
        int sum=0;
        for(int i=0;i<k;i++)
        sum+=arr[i];
        pw.println(sum);
        pw.flush();
        pw.close();
    }
} Main
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String ars[])throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw=new PrintWriter(System.out);
        String str[]=br.readLine().split(" ");
        int n=Integer.parseInt(str[0]);
        int k=Integer.parseInt(str[1]);
        str=br.readLine().split(" ");
        int arr[]=new int[n];
        for(int i=0;i<n;i++)
        arr[i]=Integer.parseInt(str[i]);
        Arrays.sort(arr);
        int sum=0;
        for(int i=0;i<k;i++)
        sum+=arr[i];
        pw.println(sum);
        pw.flush();
        pw.close();
    }
}