import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
		
		StringTokenizer st = new StringTokenizer(br.readLine());
		int N = Integer.parseInt(st.nextToken());
		int K = Integer.parseInt(st.nextToken());
		
		int[] prices = new int[N];
		
		st = new StringTokenizer(br.readLine());
		
		for(int i=0;i <prices.length; i++)
			prices[i] = Integer.parseInt(st.nextToken());
		
		Arrays.sort(prices);
		
		int sum = 0;
		for(int i=0; i<K; i++)
			sum += prices[i];
		
		bw.write(sum + "\n");
		bw.flush();
	}

} import java.io.BufferedReader; BufferedReader java.io import java.io.BufferedWriter; BufferedWriter java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.OutputStreamWriter; OutputStreamWriter java.io import java.util.Arrays; Arrays java.util import java.util.StringTokenizer; StringTokenizer java.util public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
		
		StringTokenizer st = new StringTokenizer(br.readLine());
		int N = Integer.parseInt(st.nextToken());
		int K = Integer.parseInt(st.nextToken());
		
		int[] prices = new int[N];
		
		st = new StringTokenizer(br.readLine());
		
		for(int i=0;i <prices.length; i++)
			prices[i] = Integer.parseInt(st.nextToken());
		
		Arrays.sort(prices);
		
		int sum = 0;
		for(int i=0; i<K; i++)
			sum += prices[i];
		
		bw.write(sum + "\n");
		bw.flush();
	}

} Main public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
		
		StringTokenizer st = new StringTokenizer(br.readLine());
		int N = Integer.parseInt(st.nextToken());
		int K = Integer.parseInt(st.nextToken());
		
		int[] prices = new int[N];
		
		st = new StringTokenizer(br.readLine());
		
		for(int i=0;i <prices.length; i++)
			prices[i] = Integer.parseInt(st.nextToken());
		
		Arrays.sort(prices);
		
		int sum = 0;
		for(int i=0; i<K; i++)
			sum += prices[i];
		
		bw.write(sum + "\n");
		bw.flush();
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
		
		StringTokenizer st = new StringTokenizer(br.readLine());
		int N = Integer.parseInt(st.nextToken());
		int K = Integer.parseInt(st.nextToken());
		
		int[] prices = new int[N];
		
		st = new StringTokenizer(br.readLine());
		
		for(int i=0;i <prices.length; i++)
			prices[i] = Integer.parseInt(st.nextToken());
		
		Arrays.sort(prices);
		
		int sum = 0;
		for(int i=0; i<K; i++)
			sum += prices[i];
		
		bw.write(sum + "\n");
		bw.flush();
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); bw new BufferedWriter(new OutputStreamWriter(System.out)) StringTokenizer st = new StringTokenizer(br.readLine()); st new StringTokenizer(br.readLine()) int N = Integer.parseInt(st.nextToken()); N Integer.parseInt(st.nextToken()) Integer.parseInt Integer st.nextToken() st.nextToken st int K = Integer.parseInt(st.nextToken()); K Integer.parseInt(st.nextToken()) Integer.parseInt Integer st.nextToken() st.nextToken st int[] prices = new int[N]; prices new int[N] N st = new StringTokenizer(br.readLine()) st new StringTokenizer(br.readLine()) for(int i=0;i <prices.length; i++)
			prices[i] = Integer.parseInt(st.nextToken()); int i=0; int i=0; i 0 i <prices.length i prices.length prices prices.length i++ i++ i prices[i] = Integer.parseInt(st.nextToken()); prices[i] = Integer.parseInt(st.nextToken()) prices[i] prices i Integer.parseInt(st.nextToken()) Integer.parseInt Integer st.nextToken() st.nextToken st Arrays.sort(prices) Arrays.sort Arrays prices int sum = 0; sum 0 for(int i=0; i<K; i++)
			sum += prices[i]; int i=0; int i=0; i 0 i<K i K i++ i++ i sum += prices[i]; sum += prices[i] sum prices[i] prices i bw.write(sum + "\n") bw.write bw sum + "\n" sum "\n" bw.flush() bw.flush bw String[] args args public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
		
		StringTokenizer st = new StringTokenizer(br.readLine());
		int N = Integer.parseInt(st.nextToken());
		int K = Integer.parseInt(st.nextToken());
		
		int[] prices = new int[N];
		
		st = new StringTokenizer(br.readLine());
		
		for(int i=0;i <prices.length; i++)
			prices[i] = Integer.parseInt(st.nextToken());
		
		Arrays.sort(prices);
		
		int sum = 0;
		for(int i=0; i<K; i++)
			sum += prices[i];
		
		bw.write(sum + "\n");
		bw.flush();
	}

} public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
		
		StringTokenizer st = new StringTokenizer(br.readLine());
		int N = Integer.parseInt(st.nextToken());
		int K = Integer.parseInt(st.nextToken());
		
		int[] prices = new int[N];
		
		st = new StringTokenizer(br.readLine());
		
		for(int i=0;i <prices.length; i++)
			prices[i] = Integer.parseInt(st.nextToken());
		
		Arrays.sort(prices);
		
		int sum = 0;
		for(int i=0; i<K; i++)
			sum += prices[i];
		
		bw.write(sum + "\n");
		bw.flush();
	}

} Main
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
		
		StringTokenizer st = new StringTokenizer(br.readLine());
		int N = Integer.parseInt(st.nextToken());
		int K = Integer.parseInt(st.nextToken());
		
		int[] prices = new int[N];
		
		st = new StringTokenizer(br.readLine());
		
		for(int i=0;i <prices.length; i++)
			prices[i] = Integer.parseInt(st.nextToken());
		
		Arrays.sort(prices);
		
		int sum = 0;
		for(int i=0; i<K; i++)
			sum += prices[i];
		
		bw.write(sum + "\n");
		bw.flush();
	}

}
