import java.util.*;
public class Main{
	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		int n=in.nextInt();
		int k=in.nextInt();
		Long[] arr=new Long[n];
		for(int i=0;i<n;i++){
			arr[i]=in.nextLong();
		}
		Arrays.sort(arr);
		long ans=0;
		for(int i=0;i<k;i++){
			ans+=arr[i];
		}
		System.out.print(ans);
	}
} import java.util.*; util.* java public class Main{
	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		int n=in.nextInt();
		int k=in.nextInt();
		Long[] arr=new Long[n];
		for(int i=0;i<n;i++){
			arr[i]=in.nextLong();
		}
		Arrays.sort(arr);
		long ans=0;
		for(int i=0;i<k;i++){
			ans+=arr[i];
		}
		System.out.print(ans);
	}
} Main public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		int n=in.nextInt();
		int k=in.nextInt();
		Long[] arr=new Long[n];
		for(int i=0;i<n;i++){
			arr[i]=in.nextLong();
		}
		Arrays.sort(arr);
		long ans=0;
		for(int i=0;i<k;i++){
			ans+=arr[i];
		}
		System.out.print(ans);
	} main {
		Scanner in = new Scanner(System.in);
		int n=in.nextInt();
		int k=in.nextInt();
		Long[] arr=new Long[n];
		for(int i=0;i<n;i++){
			arr[i]=in.nextLong();
		}
		Arrays.sort(arr);
		long ans=0;
		for(int i=0;i<k;i++){
			ans+=arr[i];
		}
		System.out.print(ans);
	} 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 Long[] arr=new Long[n]; arr new Long[n] n for(int i=0;i<n;i++){
			arr[i]=in.nextLong();
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			arr[i]=in.nextLong();
		} {
			arr[i]=in.nextLong();
		} arr[i]=in.nextLong() arr[i] arr i in.nextLong() in.nextLong in Arrays.sort(arr) Arrays.sort Arrays arr long ans=0; ans 0 for(int i=0;i<k;i++){
			ans+=arr[i];
		} int i=0; int i=0; i 0 i<k i k i++ i++ i {
			ans+=arr[i];
		} {
			ans+=arr[i];
		} ans+=arr[i] ans arr[i] arr i System.out.print(ans) System.out.print System.out System System.out ans String args[] args public class Main{
	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		int n=in.nextInt();
		int k=in.nextInt();
		Long[] arr=new Long[n];
		for(int i=0;i<n;i++){
			arr[i]=in.nextLong();
		}
		Arrays.sort(arr);
		long ans=0;
		for(int i=0;i<k;i++){
			ans+=arr[i];
		}
		System.out.print(ans);
	}
} public class Main{
	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		int n=in.nextInt();
		int k=in.nextInt();
		Long[] arr=new Long[n];
		for(int i=0;i<n;i++){
			arr[i]=in.nextLong();
		}
		Arrays.sort(arr);
		long ans=0;
		for(int i=0;i<k;i++){
			ans+=arr[i];
		}
		System.out.print(ans);
	}
} Main
import java.util.*;
public class Main{
	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		int n=in.nextInt();
		int k=in.nextInt();
		Long[] arr=new Long[n];
		for(int i=0;i<n;i++){
			arr[i]=in.nextLong();
		}
		Arrays.sort(arr);
		long ans=0;
		for(int i=0;i<k;i++){
			ans+=arr[i];
		}
		System.out.print(ans);
	}
}