import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		int n=in.nextInt();
		int k=in.nextInt();
		int arr[]=new int[n];
		for(int i=0;i<n;i++)
		{
			arr[i]=in.nextInt();
		}
		Arrays.sort(arr);
		int mid=0,s=0,c=0;
		while(mid<=arr.length-1 && c!=k)
		{
			s=s+arr[mid];
			c++;
			mid++;
		}
		System.out.println(s);

	}

} import java.util.*; util.* java public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		int n=in.nextInt();
		int k=in.nextInt();
		int arr[]=new int[n];
		for(int i=0;i<n;i++)
		{
			arr[i]=in.nextInt();
		}
		Arrays.sort(arr);
		int mid=0,s=0,c=0;
		while(mid<=arr.length-1 && c!=k)
		{
			s=s+arr[mid];
			c++;
			mid++;
		}
		System.out.println(s);

	}

} Main public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		int n=in.nextInt();
		int k=in.nextInt();
		int arr[]=new int[n];
		for(int i=0;i<n;i++)
		{
			arr[i]=in.nextInt();
		}
		Arrays.sort(arr);
		int mid=0,s=0,c=0;
		while(mid<=arr.length-1 && c!=k)
		{
			s=s+arr[mid];
			c++;
			mid++;
		}
		System.out.println(s);

	} main {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		int n=in.nextInt();
		int k=in.nextInt();
		int arr[]=new int[n];
		for(int i=0;i<n;i++)
		{
			arr[i]=in.nextInt();
		}
		Arrays.sort(arr);
		int mid=0,s=0,c=0;
		while(mid<=arr.length-1 && c!=k)
		{
			s=s+arr[mid];
			c++;
			mid++;
		}
		System.out.println(s);

	} Scanner in = new Scanner(System.in); in new Scanner(System.in) int n=in.nextInt(); n in.nextInt() in.nextInt in int k=in.nextInt(); k in.nextInt() in.nextInt in int arr[]=new int[n]; arr new int[n] n for(int i=0;i<n;i++)
		{
			arr[i]=in.nextInt();
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			arr[i]=in.nextInt();
		} {
			arr[i]=in.nextInt();
		} arr[i]=in.nextInt() arr[i] arr i in.nextInt() in.nextInt in Arrays.sort(arr) Arrays.sort Arrays arr int mid=0 mid 0 s=0 s 0 c=0; c 0 while(mid<=arr.length-1 && c!=k)
		{
			s=s+arr[mid];
			c++;
			mid++;
		} mid<=arr.length-1 && c!=k mid<=arr.length-1 mid arr.length-1 arr.length arr arr.length 1 c!=k c k {
			s=s+arr[mid];
			c++;
			mid++;
		} s=s+arr[mid] s s+arr[mid] s arr[mid] arr mid c++ c mid++ mid System.out.println(s) System.out.println System.out System System.out s String[] args args public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		int n=in.nextInt();
		int k=in.nextInt();
		int arr[]=new int[n];
		for(int i=0;i<n;i++)
		{
			arr[i]=in.nextInt();
		}
		Arrays.sort(arr);
		int mid=0,s=0,c=0;
		while(mid<=arr.length-1 && c!=k)
		{
			s=s+arr[mid];
			c++;
			mid++;
		}
		System.out.println(s);

	}

} public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		int n=in.nextInt();
		int k=in.nextInt();
		int arr[]=new int[n];
		for(int i=0;i<n;i++)
		{
			arr[i]=in.nextInt();
		}
		Arrays.sort(arr);
		int mid=0,s=0,c=0;
		while(mid<=arr.length-1 && c!=k)
		{
			s=s+arr[mid];
			c++;
			mid++;
		}
		System.out.println(s);

	}

} Main
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		int n=in.nextInt();
		int k=in.nextInt();
		int arr[]=new int[n];
		for(int i=0;i<n;i++)
		{
			arr[i]=in.nextInt();
		}
		Arrays.sort(arr);
		int mid=0,s=0,c=0;
		while(mid<=arr.length-1 && c!=k)
		{
			s=s+arr[mid];
			c++;
			mid++;
		}
		System.out.println(s);

	}

}
