import java.util.Scanner;
import java.util.Arrays;
public class Main
{
	public static void main(String args[])
	{
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int k = s.nextInt();
		int fruits[] = new int[n];
		for(int i=0;i<n;i++) fruits[i] = s.nextInt();
		solver(fruits,k);
	}
	private static void solver(int arr[],int k)
	{
		int min = 0;
		Arrays.sort(arr);
		for(int i=0;i<k;i++) min = min+arr[i];
		System.out.println(min); 
	}
} import java.util.Scanner; Scanner java.util import java.util.Arrays; Arrays java.util public class Main
{
	public static void main(String args[])
	{
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int k = s.nextInt();
		int fruits[] = new int[n];
		for(int i=0;i<n;i++) fruits[i] = s.nextInt();
		solver(fruits,k);
	}
	private static void solver(int arr[],int k)
	{
		int min = 0;
		Arrays.sort(arr);
		for(int i=0;i<k;i++) min = min+arr[i];
		System.out.println(min); 
	}
} Main public static void main(String args[])
	{
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int k = s.nextInt();
		int fruits[] = new int[n];
		for(int i=0;i<n;i++) fruits[i] = s.nextInt();
		solver(fruits,k);
	} main {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int k = s.nextInt();
		int fruits[] = new int[n];
		for(int i=0;i<n;i++) fruits[i] = s.nextInt();
		solver(fruits,k);
	} Scanner s = new Scanner(System.in); s new Scanner(System.in) int n = s.nextInt(); n s.nextInt() s.nextInt s int k = s.nextInt(); k s.nextInt() s.nextInt s int fruits[] = new int[n]; fruits new int[n] n for(int i=0;i<n;i++) fruits[i] = s.nextInt(); int i=0; int i=0; i 0 i<n i n i++ i++ i fruits[i] = s.nextInt(); fruits[i] = s.nextInt() fruits[i] fruits i s.nextInt() s.nextInt s solver(fruits,k) solver fruits k String args[] args private static void solver(int arr[],int k)
	{
		int min = 0;
		Arrays.sort(arr);
		for(int i=0;i<k;i++) min = min+arr[i];
		System.out.println(min); 
	} solver {
		int min = 0;
		Arrays.sort(arr);
		for(int i=0;i<k;i++) min = min+arr[i];
		System.out.println(min); 
	} int min = 0; min 0 Arrays.sort(arr) Arrays.sort Arrays arr for(int i=0;i<k;i++) min = min+arr[i]; int i=0; int i=0; i 0 i<k i k i++ i++ i min = min+arr[i]; min = min+arr[i] min min+arr[i] min arr[i] arr i System.out.println(min) System.out.println System.out System System.out min int arr[] arr int k k public class Main
{
	public static void main(String args[])
	{
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int k = s.nextInt();
		int fruits[] = new int[n];
		for(int i=0;i<n;i++) fruits[i] = s.nextInt();
		solver(fruits,k);
	}
	private static void solver(int arr[],int k)
	{
		int min = 0;
		Arrays.sort(arr);
		for(int i=0;i<k;i++) min = min+arr[i];
		System.out.println(min); 
	}
} public class Main
{
	public static void main(String args[])
	{
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int k = s.nextInt();
		int fruits[] = new int[n];
		for(int i=0;i<n;i++) fruits[i] = s.nextInt();
		solver(fruits,k);
	}
	private static void solver(int arr[],int k)
	{
		int min = 0;
		Arrays.sort(arr);
		for(int i=0;i<k;i++) min = min+arr[i];
		System.out.println(min); 
	}
} Main
import java.util.Scanner;
import java.util.Arrays;
public class Main
{
	public static void main(String args[])
	{
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int k = s.nextInt();
		int fruits[] = new int[n];
		for(int i=0;i<n;i++) fruits[i] = s.nextInt();
		solver(fruits,k);
	}
	private static void solver(int arr[],int k)
	{
		int min = 0;
		Arrays.sort(arr);
		for(int i=0;i<k;i++) min = min+arr[i];
		System.out.println(min); 
	}
}