import java.util.*;
public class Main {
	//定義関数から参照できる変数定義はこの辺
	//static Var_form Var_name;

	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
		//long Var_name = sc.nextLong();
		int ans=0;
		int N = sc.nextInt();
		int K = sc.nextInt();
		int ary[]=new int[N+1];
		ary[0]=0;
		for(int i=1;i<=N;i++){
			ary[i]=sc.nextInt();
		}
		Arrays.sort(ary);
		for(int i=1;i<=K;i++){
			ans=ans+ary[i];
		}



		System.out.println(ans);
		//System.out.print(ans);
    }
} import java.util.*; util.* java public class Main {
	//定義関数から参照できる変数定義はこの辺
	//static Var_form Var_name;

	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
		//long Var_name = sc.nextLong();
		int ans=0;
		int N = sc.nextInt();
		int K = sc.nextInt();
		int ary[]=new int[N+1];
		ary[0]=0;
		for(int i=1;i<=N;i++){
			ary[i]=sc.nextInt();
		}
		Arrays.sort(ary);
		for(int i=1;i<=K;i++){
			ans=ans+ary[i];
		}



		System.out.println(ans);
		//System.out.print(ans);
    }
} Main public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
		//long Var_name = sc.nextLong();
		int ans=0;
		int N = sc.nextInt();
		int K = sc.nextInt();
		int ary[]=new int[N+1];
		ary[0]=0;
		for(int i=1;i<=N;i++){
			ary[i]=sc.nextInt();
		}
		Arrays.sort(ary);
		for(int i=1;i<=K;i++){
			ans=ans+ary[i];
		}



		System.out.println(ans);
		//System.out.print(ans);
    } main {
    	Scanner sc = new Scanner(System.in);
		//long Var_name = sc.nextLong();
		int ans=0;
		int N = sc.nextInt();
		int K = sc.nextInt();
		int ary[]=new int[N+1];
		ary[0]=0;
		for(int i=1;i<=N;i++){
			ary[i]=sc.nextInt();
		}
		Arrays.sort(ary);
		for(int i=1;i<=K;i++){
			ans=ans+ary[i];
		}



		System.out.println(ans);
		//System.out.print(ans);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int ans=0; ans 0 int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int K = sc.nextInt(); K sc.nextInt() sc.nextInt sc int ary[]=new int[N+1]; ary new int[N+1] N+1 N 1 ary[0]=0 ary[0] ary 0 0 for(int i=1;i<=N;i++){
			ary[i]=sc.nextInt();
		} int i=1; int i=1; i 1 i<=N i N i++ i++ i {
			ary[i]=sc.nextInt();
		} {
			ary[i]=sc.nextInt();
		} ary[i]=sc.nextInt() ary[i] ary i sc.nextInt() sc.nextInt sc Arrays.sort(ary) Arrays.sort Arrays ary for(int i=1;i<=K;i++){
			ans=ans+ary[i];
		} int i=1; int i=1; i 1 i<=K i K i++ i++ i {
			ans=ans+ary[i];
		} {
			ans=ans+ary[i];
		} ans=ans+ary[i] ans ans+ary[i] ans ary[i] ary i System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
	//定義関数から参照できる変数定義はこの辺
	//static Var_form Var_name;

	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
		//long Var_name = sc.nextLong();
		int ans=0;
		int N = sc.nextInt();
		int K = sc.nextInt();
		int ary[]=new int[N+1];
		ary[0]=0;
		for(int i=1;i<=N;i++){
			ary[i]=sc.nextInt();
		}
		Arrays.sort(ary);
		for(int i=1;i<=K;i++){
			ans=ans+ary[i];
		}



		System.out.println(ans);
		//System.out.print(ans);
    }
} public class Main {
	//定義関数から参照できる変数定義はこの辺
	//static Var_form Var_name;

	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
		//long Var_name = sc.nextLong();
		int ans=0;
		int N = sc.nextInt();
		int K = sc.nextInt();
		int ary[]=new int[N+1];
		ary[0]=0;
		for(int i=1;i<=N;i++){
			ary[i]=sc.nextInt();
		}
		Arrays.sort(ary);
		for(int i=1;i<=K;i++){
			ans=ans+ary[i];
		}



		System.out.println(ans);
		//System.out.print(ans);
    }
} Main
import java.util.*;
public class Main {
	//定義関数から参照できる変数定義はこの辺
	//static Var_form Var_name;

	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
		//long Var_name = sc.nextLong();
		int ans=0;
		int N = sc.nextInt();
		int K = sc.nextInt();
		int ary[]=new int[N+1];
		ary[0]=0;
		for(int i=1;i<=N;i++){
			ary[i]=sc.nextInt();
		}
		Arrays.sort(ary);
		for(int i=1;i<=K;i++){
			ans=ans+ary[i];
		}



		System.out.println(ans);
		//System.out.print(ans);
    }
}