import java.util.*;
import java.lang.*;
import java.io.*;

class Main {
    
    private static BufferedReader br;
    private static StringTokenizer strz;
    
	public static void main (String[] args) throws java.lang.Exception {
		br=  new BufferedReader(new InputStreamReader(System.in));
		strz = new StringTokenizer(br.readLine());
		int n = Integer.parseInt(strz.nextToken());
		int k = Integer.parseInt(strz.nextToken());
		
		int[] arr = new int[n];
		
		strz = new StringTokenizer(br.readLine());
		for(int i= 0; i < n; ++i)
		    arr[i] = Integer.parseInt(strz.nextToken());
		    
		Arrays.sort(arr);
		    
		int cost = 0;
		for(int i = 0; i < k; ++i)
		    cost += arr[i];
		System.out.println(cost);
	}
} import java.util.*; util.* java import java.lang.*; lang.* java import java.io.*; io.* java class Main {
    
    private static BufferedReader br;
    private static StringTokenizer strz;
    
	public static void main (String[] args) throws java.lang.Exception {
		br=  new BufferedReader(new InputStreamReader(System.in));
		strz = new StringTokenizer(br.readLine());
		int n = Integer.parseInt(strz.nextToken());
		int k = Integer.parseInt(strz.nextToken());
		
		int[] arr = new int[n];
		
		strz = new StringTokenizer(br.readLine());
		for(int i= 0; i < n; ++i)
		    arr[i] = Integer.parseInt(strz.nextToken());
		    
		Arrays.sort(arr);
		    
		int cost = 0;
		for(int i = 0; i < k; ++i)
		    cost += arr[i];
		System.out.println(cost);
	}
} Main private static BufferedReader br; br private static StringTokenizer strz; strz public static void main (String[] args) throws java.lang.Exception {
		br=  new BufferedReader(new InputStreamReader(System.in));
		strz = new StringTokenizer(br.readLine());
		int n = Integer.parseInt(strz.nextToken());
		int k = Integer.parseInt(strz.nextToken());
		
		int[] arr = new int[n];
		
		strz = new StringTokenizer(br.readLine());
		for(int i= 0; i < n; ++i)
		    arr[i] = Integer.parseInt(strz.nextToken());
		    
		Arrays.sort(arr);
		    
		int cost = 0;
		for(int i = 0; i < k; ++i)
		    cost += arr[i];
		System.out.println(cost);
	} main {
		br=  new BufferedReader(new InputStreamReader(System.in));
		strz = new StringTokenizer(br.readLine());
		int n = Integer.parseInt(strz.nextToken());
		int k = Integer.parseInt(strz.nextToken());
		
		int[] arr = new int[n];
		
		strz = new StringTokenizer(br.readLine());
		for(int i= 0; i < n; ++i)
		    arr[i] = Integer.parseInt(strz.nextToken());
		    
		Arrays.sort(arr);
		    
		int cost = 0;
		for(int i = 0; i < k; ++i)
		    cost += arr[i];
		System.out.println(cost);
	} br=  new BufferedReader(new InputStreamReader(System.in)) br new BufferedReader(new InputStreamReader(System.in)) strz = new StringTokenizer(br.readLine()) strz new StringTokenizer(br.readLine()) int n = Integer.parseInt(strz.nextToken()); n Integer.parseInt(strz.nextToken()) Integer.parseInt Integer strz.nextToken() strz.nextToken strz int k = Integer.parseInt(strz.nextToken()); k Integer.parseInt(strz.nextToken()) Integer.parseInt Integer strz.nextToken() strz.nextToken strz int[] arr = new int[n]; arr new int[n] n strz = new StringTokenizer(br.readLine()) strz new StringTokenizer(br.readLine()) for(int i= 0; i < n; ++i)
		    arr[i] = Integer.parseInt(strz.nextToken()); int i= 0; int i= 0; i 0 i < n i n ++i ++i i arr[i] = Integer.parseInt(strz.nextToken()); arr[i] = Integer.parseInt(strz.nextToken()) arr[i] arr i Integer.parseInt(strz.nextToken()) Integer.parseInt Integer strz.nextToken() strz.nextToken strz Arrays.sort(arr) Arrays.sort Arrays arr int cost = 0; cost 0 for(int i = 0; i < k; ++i)
		    cost += arr[i]; int i = 0; int i = 0; i 0 i < k i k ++i ++i i cost += arr[i]; cost += arr[i] cost arr[i] arr i System.out.println(cost) System.out.println System.out System System.out cost String[] args args
import java.util.*;
import java.lang.*;
import java.io.*;

class Main {
    
    private static BufferedReader br;
    private static StringTokenizer strz;
    
	public static void main (String[] args) throws java.lang.Exception {
		br=  new BufferedReader(new InputStreamReader(System.in));
		strz = new StringTokenizer(br.readLine());
		int n = Integer.parseInt(strz.nextToken());
		int k = Integer.parseInt(strz.nextToken());
		
		int[] arr = new int[n];
		
		strz = new StringTokenizer(br.readLine());
		for(int i= 0; i < n; ++i)
		    arr[i] = Integer.parseInt(strz.nextToken());
		    
		Arrays.sort(arr);
		    
		int cost = 0;
		for(int i = 0; i < k; ++i)
		    cost += arr[i];
		System.out.println(cost);
	}
}
