import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    public static void main(String args[]) throws IOException {

	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String numberArray[] = br.readLine().split(" ");
	int N = Integer.parseInt(numberArray[0]);
	int K = Integer.parseInt(numberArray[1]);

	String inputArray[] = br.readLine().split(" ");
	int priceArray[] = new int[N];
	for (int i = 0; i < N; i++) {
	    priceArray[i] = Integer.parseInt(inputArray[i]);
	}

	Arrays.sort(priceArray);
	int result = 0;
	for (int j = 0; j < K; j++) {
	    result += priceArray[j];
	}
	System.out.println(result);
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.Arrays; Arrays java.util public class Main {
    public static void main(String args[]) throws IOException {

	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String numberArray[] = br.readLine().split(" ");
	int N = Integer.parseInt(numberArray[0]);
	int K = Integer.parseInt(numberArray[1]);

	String inputArray[] = br.readLine().split(" ");
	int priceArray[] = new int[N];
	for (int i = 0; i < N; i++) {
	    priceArray[i] = Integer.parseInt(inputArray[i]);
	}

	Arrays.sort(priceArray);
	int result = 0;
	for (int j = 0; j < K; j++) {
	    result += priceArray[j];
	}
	System.out.println(result);
    }
} Main public static void main(String args[]) throws IOException {

	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String numberArray[] = br.readLine().split(" ");
	int N = Integer.parseInt(numberArray[0]);
	int K = Integer.parseInt(numberArray[1]);

	String inputArray[] = br.readLine().split(" ");
	int priceArray[] = new int[N];
	for (int i = 0; i < N; i++) {
	    priceArray[i] = Integer.parseInt(inputArray[i]);
	}

	Arrays.sort(priceArray);
	int result = 0;
	for (int j = 0; j < K; j++) {
	    result += priceArray[j];
	}
	System.out.println(result);
    } main {

	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String numberArray[] = br.readLine().split(" ");
	int N = Integer.parseInt(numberArray[0]);
	int K = Integer.parseInt(numberArray[1]);

	String inputArray[] = br.readLine().split(" ");
	int priceArray[] = new int[N];
	for (int i = 0; i < N; i++) {
	    priceArray[i] = Integer.parseInt(inputArray[i]);
	}

	Arrays.sort(priceArray);
	int result = 0;
	for (int j = 0; j < K; j++) {
	    result += priceArray[j];
	}
	System.out.println(result);
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String numberArray[] = br.readLine().split(" "); numberArray br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int N = Integer.parseInt(numberArray[0]); N Integer.parseInt(numberArray[0]) Integer.parseInt Integer numberArray[0] numberArray 0 int K = Integer.parseInt(numberArray[1]); K Integer.parseInt(numberArray[1]) Integer.parseInt Integer numberArray[1] numberArray 1 String inputArray[] = br.readLine().split(" "); inputArray br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int priceArray[] = new int[N]; priceArray new int[N] N for (int i = 0; i < N; i++) {
	    priceArray[i] = Integer.parseInt(inputArray[i]);
	} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
	    priceArray[i] = Integer.parseInt(inputArray[i]);
	} {
	    priceArray[i] = Integer.parseInt(inputArray[i]);
	} priceArray[i] = Integer.parseInt(inputArray[i]) priceArray[i] priceArray i Integer.parseInt(inputArray[i]) Integer.parseInt Integer inputArray[i] inputArray i Arrays.sort(priceArray) Arrays.sort Arrays priceArray int result = 0; result 0 for (int j = 0; j < K; j++) {
	    result += priceArray[j];
	} int j = 0; int j = 0; j 0 j < K j K j++ j++ j {
	    result += priceArray[j];
	} {
	    result += priceArray[j];
	} result += priceArray[j] result priceArray[j] priceArray j System.out.println(result) System.out.println System.out System System.out result String args[] args public class Main {
    public static void main(String args[]) throws IOException {

	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String numberArray[] = br.readLine().split(" ");
	int N = Integer.parseInt(numberArray[0]);
	int K = Integer.parseInt(numberArray[1]);

	String inputArray[] = br.readLine().split(" ");
	int priceArray[] = new int[N];
	for (int i = 0; i < N; i++) {
	    priceArray[i] = Integer.parseInt(inputArray[i]);
	}

	Arrays.sort(priceArray);
	int result = 0;
	for (int j = 0; j < K; j++) {
	    result += priceArray[j];
	}
	System.out.println(result);
    }
} public class Main {
    public static void main(String args[]) throws IOException {

	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String numberArray[] = br.readLine().split(" ");
	int N = Integer.parseInt(numberArray[0]);
	int K = Integer.parseInt(numberArray[1]);

	String inputArray[] = br.readLine().split(" ");
	int priceArray[] = new int[N];
	for (int i = 0; i < N; i++) {
	    priceArray[i] = Integer.parseInt(inputArray[i]);
	}

	Arrays.sort(priceArray);
	int result = 0;
	for (int j = 0; j < K; j++) {
	    result += priceArray[j];
	}
	System.out.println(result);
    }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    public static void main(String args[]) throws IOException {

	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String numberArray[] = br.readLine().split(" ");
	int N = Integer.parseInt(numberArray[0]);
	int K = Integer.parseInt(numberArray[1]);

	String inputArray[] = br.readLine().split(" ");
	int priceArray[] = new int[N];
	for (int i = 0; i < N; i++) {
	    priceArray[i] = Integer.parseInt(inputArray[i]);
	}

	Arrays.sort(priceArray);
	int result = 0;
	for (int j = 0; j < K; j++) {
	    result += priceArray[j];
	}
	System.out.println(result);
    }
}
