import java.util.Arrays;
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		String tmp = sc.nextLine();
		Integer [] p = new Integer[a];
		for (int i=0; i<a; i++) {
			p[i]= sc.nextInt();
		}
		Arrays.sort(p);
		int ans = 0;
		for (int i=0; i<b; i++) {
			ans +=p[i];
		}

		sc.close();
		System.out.println(ans);
	}
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		String tmp = sc.nextLine();
		Integer [] p = new Integer[a];
		for (int i=0; i<a; i++) {
			p[i]= sc.nextInt();
		}
		Arrays.sort(p);
		int ans = 0;
		for (int i=0; i<b; i++) {
			ans +=p[i];
		}

		sc.close();
		System.out.println(ans);
	}
} Main public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		String tmp = sc.nextLine();
		Integer [] p = new Integer[a];
		for (int i=0; i<a; i++) {
			p[i]= sc.nextInt();
		}
		Arrays.sort(p);
		int ans = 0;
		for (int i=0; i<b; i++) {
			ans +=p[i];
		}

		sc.close();
		System.out.println(ans);
	} main {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		String tmp = sc.nextLine();
		Integer [] p = new Integer[a];
		for (int i=0; i<a; i++) {
			p[i]= sc.nextInt();
		}
		Arrays.sort(p);
		int ans = 0;
		for (int i=0; i<b; i++) {
			ans +=p[i];
		}

		sc.close();
		System.out.println(ans);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc int b = sc.nextInt(); b sc.nextInt() sc.nextInt sc String tmp = sc.nextLine(); tmp sc.nextLine() sc.nextLine sc Integer [] p = new Integer[a]; p new Integer[a] a for (int i=0; i<a; i++) {
			p[i]= sc.nextInt();
		} int i=0; int i=0; i 0 i<a i a i++ i++ i {
			p[i]= sc.nextInt();
		} {
			p[i]= sc.nextInt();
		} p[i]= sc.nextInt() p[i] p i sc.nextInt() sc.nextInt sc Arrays.sort(p) Arrays.sort Arrays p int ans = 0; ans 0 for (int i=0; i<b; i++) {
			ans +=p[i];
		} int i=0; int i=0; i 0 i<b i b i++ i++ i {
			ans +=p[i];
		} {
			ans +=p[i];
		} ans +=p[i] ans p[i] p i sc.close() sc.close sc 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)
	{
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		String tmp = sc.nextLine();
		Integer [] p = new Integer[a];
		for (int i=0; i<a; i++) {
			p[i]= sc.nextInt();
		}
		Arrays.sort(p);
		int ans = 0;
		for (int i=0; i<b; i++) {
			ans +=p[i];
		}

		sc.close();
		System.out.println(ans);
	}
} public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		String tmp = sc.nextLine();
		Integer [] p = new Integer[a];
		for (int i=0; i<a; i++) {
			p[i]= sc.nextInt();
		}
		Arrays.sort(p);
		int ans = 0;
		for (int i=0; i<b; i++) {
			ans +=p[i];
		}

		sc.close();
		System.out.println(ans);
	}
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		String tmp = sc.nextLine();
		Integer [] p = new Integer[a];
		for (int i=0; i<a; i++) {
			p[i]= sc.nextInt();
		}
		Arrays.sort(p);
		int ans = 0;
		for (int i=0; i<b; i++) {
			ans +=p[i];
		}

		sc.close();
		System.out.println(ans);
	}
}
