import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
      	int k = scn.nextInt();
		int[] a = new int[n];
		for(int i=0; i<a.length; i++){
			a[i] = scn.nextInt();
		}
      	Arrays.sort(a);
      	int ans = 0;
      	for(int i=0; i<k; i++) ans+=a[i];
      	System.out.println(ans);
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
      	int k = scn.nextInt();
		int[] a = new int[n];
		for(int i=0; i<a.length; i++){
			a[i] = scn.nextInt();
		}
      	Arrays.sort(a);
      	int ans = 0;
      	for(int i=0; i<k; i++) ans+=a[i];
      	System.out.println(ans);
	}
} Main public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
      	int k = scn.nextInt();
		int[] a = new int[n];
		for(int i=0; i<a.length; i++){
			a[i] = scn.nextInt();
		}
      	Arrays.sort(a);
      	int ans = 0;
      	for(int i=0; i<k; i++) ans+=a[i];
      	System.out.println(ans);
	} main {
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
      	int k = scn.nextInt();
		int[] a = new int[n];
		for(int i=0; i<a.length; i++){
			a[i] = scn.nextInt();
		}
      	Arrays.sort(a);
      	int ans = 0;
      	for(int i=0; i<k; i++) ans+=a[i];
      	System.out.println(ans);
	} Scanner scn = new Scanner(System.in); scn new Scanner(System.in) int n = scn.nextInt(); n scn.nextInt() scn.nextInt scn int k = scn.nextInt(); k scn.nextInt() scn.nextInt scn int[] a = new int[n]; a new int[n] n for(int i=0; i<a.length; i++){
			a[i] = scn.nextInt();
		} int i=0; int i=0; i 0 i<a.length i a.length a a.length i++ i++ i {
			a[i] = scn.nextInt();
		} {
			a[i] = scn.nextInt();
		} a[i] = scn.nextInt() a[i] a i scn.nextInt() scn.nextInt scn Arrays.sort(a) Arrays.sort Arrays a int ans = 0; ans 0 for(int i=0; i<k; i++) ans+=a[i]; int i=0; int i=0; i 0 i<k i k i++ i++ i ans+=a[i]; ans+=a[i] ans a[i] a i System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
      	int k = scn.nextInt();
		int[] a = new int[n];
		for(int i=0; i<a.length; i++){
			a[i] = scn.nextInt();
		}
      	Arrays.sort(a);
      	int ans = 0;
      	for(int i=0; i<k; i++) ans+=a[i];
      	System.out.println(ans);
	}
} public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
      	int k = scn.nextInt();
		int[] a = new int[n];
		for(int i=0; i<a.length; i++){
			a[i] = scn.nextInt();
		}
      	Arrays.sort(a);
      	int ans = 0;
      	for(int i=0; i<k; i++) ans+=a[i];
      	System.out.println(ans);
	}
} Main
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
      	int k = scn.nextInt();
		int[] a = new int[n];
		for(int i=0; i<a.length; i++){
			a[i] = scn.nextInt();
		}
      	Arrays.sort(a);
      	int ans = 0;
      	for(int i=0; i<k; i++) ans+=a[i];
      	System.out.println(ans);
	}
}