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

public class Main {
	
	private static int MixJuice(int[] arr, int n, int k) {
		
		Arrays.sort(arr);
		int sum=0;
		for(int i=0;i<k;i++)
		{
			sum+=arr[i];
		}
		return sum;
	}

	public static void main(String[] args) {
			Scanner s= new Scanner(System.in);
//		  char s1= s.next().charAt(0);
//		  
//		  if(s1 >='A' && s1 <= 'Z')
//		    System.out.println("A");
//		   else
//		  	System.out.println("a");
		  
		  int n = s.nextInt();
		  int k=s.nextInt();
		  int[] arr = new int[n];
		  for(int i=0;i<arr.length;i++)
		  {
			  arr[i]=s.nextInt();
		  }
		  
		  int result=MixJuice(arr,n,k);
		  System.out.println(result);
	}

	

} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
	
	private static int MixJuice(int[] arr, int n, int k) {
		
		Arrays.sort(arr);
		int sum=0;
		for(int i=0;i<k;i++)
		{
			sum+=arr[i];
		}
		return sum;
	}

	public static void main(String[] args) {
			Scanner s= new Scanner(System.in);
//		  char s1= s.next().charAt(0);
//		  
//		  if(s1 >='A' && s1 <= 'Z')
//		    System.out.println("A");
//		   else
//		  	System.out.println("a");
		  
		  int n = s.nextInt();
		  int k=s.nextInt();
		  int[] arr = new int[n];
		  for(int i=0;i<arr.length;i++)
		  {
			  arr[i]=s.nextInt();
		  }
		  
		  int result=MixJuice(arr,n,k);
		  System.out.println(result);
	}

	

} Main private static int MixJuice(int[] arr, int n, int k) {
		
		Arrays.sort(arr);
		int sum=0;
		for(int i=0;i<k;i++)
		{
			sum+=arr[i];
		}
		return sum;
	} MixJuice {
		
		Arrays.sort(arr);
		int sum=0;
		for(int i=0;i<k;i++)
		{
			sum+=arr[i];
		}
		return sum;
	} Arrays.sort(arr) Arrays.sort Arrays arr int sum=0; sum 0 for(int i=0;i<k;i++)
		{
			sum+=arr[i];
		} int i=0; int i=0; i 0 i<k i k i++ i++ i {
			sum+=arr[i];
		} {
			sum+=arr[i];
		} sum+=arr[i] sum arr[i] arr i return sum; sum int[] arr arr int n n int k k public static void main(String[] args) {
			Scanner s= new Scanner(System.in);
//		  char s1= s.next().charAt(0);
//		  
//		  if(s1 >='A' && s1 <= 'Z')
//		    System.out.println("A");
//		   else
//		  	System.out.println("a");
		  
		  int n = s.nextInt();
		  int k=s.nextInt();
		  int[] arr = new int[n];
		  for(int i=0;i<arr.length;i++)
		  {
			  arr[i]=s.nextInt();
		  }
		  
		  int result=MixJuice(arr,n,k);
		  System.out.println(result);
	} main {
			Scanner s= new Scanner(System.in);
//		  char s1= s.next().charAt(0);
//		  
//		  if(s1 >='A' && s1 <= 'Z')
//		    System.out.println("A");
//		   else
//		  	System.out.println("a");
		  
		  int n = s.nextInt();
		  int k=s.nextInt();
		  int[] arr = new int[n];
		  for(int i=0;i<arr.length;i++)
		  {
			  arr[i]=s.nextInt();
		  }
		  
		  int result=MixJuice(arr,n,k);
		  System.out.println(result);
	} 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[] arr = new int[n]; arr new int[n] n for(int i=0;i<arr.length;i++)
		  {
			  arr[i]=s.nextInt();
		  } int i=0; int i=0; i 0 i<arr.length i arr.length arr arr.length i++ i++ i {
			  arr[i]=s.nextInt();
		  } {
			  arr[i]=s.nextInt();
		  } arr[i]=s.nextInt() arr[i] arr i s.nextInt() s.nextInt s int result=MixJuice(arr,n,k); result MixJuice(arr,n,k) MixJuice arr n k System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main {
	
	private static int MixJuice(int[] arr, int n, int k) {
		
		Arrays.sort(arr);
		int sum=0;
		for(int i=0;i<k;i++)
		{
			sum+=arr[i];
		}
		return sum;
	}

	public static void main(String[] args) {
			Scanner s= new Scanner(System.in);
//		  char s1= s.next().charAt(0);
//		  
//		  if(s1 >='A' && s1 <= 'Z')
//		    System.out.println("A");
//		   else
//		  	System.out.println("a");
		  
		  int n = s.nextInt();
		  int k=s.nextInt();
		  int[] arr = new int[n];
		  for(int i=0;i<arr.length;i++)
		  {
			  arr[i]=s.nextInt();
		  }
		  
		  int result=MixJuice(arr,n,k);
		  System.out.println(result);
	}

	

} public class Main {
	
	private static int MixJuice(int[] arr, int n, int k) {
		
		Arrays.sort(arr);
		int sum=0;
		for(int i=0;i<k;i++)
		{
			sum+=arr[i];
		}
		return sum;
	}

	public static void main(String[] args) {
			Scanner s= new Scanner(System.in);
//		  char s1= s.next().charAt(0);
//		  
//		  if(s1 >='A' && s1 <= 'Z')
//		    System.out.println("A");
//		   else
//		  	System.out.println("a");
		  
		  int n = s.nextInt();
		  int k=s.nextInt();
		  int[] arr = new int[n];
		  for(int i=0;i<arr.length;i++)
		  {
			  arr[i]=s.nextInt();
		  }
		  
		  int result=MixJuice(arr,n,k);
		  System.out.println(result);
	}

	

} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	
	private static int MixJuice(int[] arr, int n, int k) {
		
		Arrays.sort(arr);
		int sum=0;
		for(int i=0;i<k;i++)
		{
			sum+=arr[i];
		}
		return sum;
	}

	public static void main(String[] args) {
			Scanner s= new Scanner(System.in);
//		  char s1= s.next().charAt(0);
//		  
//		  if(s1 >='A' && s1 <= 'Z')
//		    System.out.println("A");
//		   else
//		  	System.out.println("a");
		  
		  int n = s.nextInt();
		  int k=s.nextInt();
		  int[] arr = new int[n];
		  for(int i=0;i<arr.length;i++)
		  {
			  arr[i]=s.nextInt();
		  }
		  
		  int result=MixJuice(arr,n,k);
		  System.out.println(result);
	}

	

}
