import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int K = scanner.nextInt();
		ArrayList<Integer> prices = new ArrayList<>();
		int total = 0;

		for (int i = 0; i < N; i++) {
			int p = scanner.nextInt();
			prices.add(p);
		}

		Collections.sort(prices);

		for (int j = 0; j < K; j++) {
			int price = prices.get(j);
			total += price;
		}

		System.out.println(total);
	}

} import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int K = scanner.nextInt();
		ArrayList<Integer> prices = new ArrayList<>();
		int total = 0;

		for (int i = 0; i < N; i++) {
			int p = scanner.nextInt();
			prices.add(p);
		}

		Collections.sort(prices);

		for (int j = 0; j < K; j++) {
			int price = prices.get(j);
			total += price;
		}

		System.out.println(total);
	}

} Main public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int K = scanner.nextInt();
		ArrayList<Integer> prices = new ArrayList<>();
		int total = 0;

		for (int i = 0; i < N; i++) {
			int p = scanner.nextInt();
			prices.add(p);
		}

		Collections.sort(prices);

		for (int j = 0; j < K; j++) {
			int price = prices.get(j);
			total += price;
		}

		System.out.println(total);
	} main {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int K = scanner.nextInt();
		ArrayList<Integer> prices = new ArrayList<>();
		int total = 0;

		for (int i = 0; i < N; i++) {
			int p = scanner.nextInt();
			prices.add(p);
		}

		Collections.sort(prices);

		for (int j = 0; j < K; j++) {
			int price = prices.get(j);
			total += price;
		}

		System.out.println(total);
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int N = scanner.nextInt(); N scanner.nextInt() scanner.nextInt scanner int K = scanner.nextInt(); K scanner.nextInt() scanner.nextInt scanner ArrayList<Integer> prices = new ArrayList<>(); prices new ArrayList<>() int total = 0; total 0 for (int i = 0; i < N; i++) {
			int p = scanner.nextInt();
			prices.add(p);
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			int p = scanner.nextInt();
			prices.add(p);
		} {
			int p = scanner.nextInt();
			prices.add(p);
		} int p = scanner.nextInt(); p scanner.nextInt() scanner.nextInt scanner prices.add(p) prices.add prices p Collections.sort(prices) Collections.sort Collections prices for (int j = 0; j < K; j++) {
			int price = prices.get(j);
			total += price;
		} int j = 0; int j = 0; j 0 j < K j K j++ j++ j {
			int price = prices.get(j);
			total += price;
		} {
			int price = prices.get(j);
			total += price;
		} int price = prices.get(j); price prices.get(j) prices.get prices j total += price total price System.out.println(total) System.out.println System.out System System.out total String[] args args public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int K = scanner.nextInt();
		ArrayList<Integer> prices = new ArrayList<>();
		int total = 0;

		for (int i = 0; i < N; i++) {
			int p = scanner.nextInt();
			prices.add(p);
		}

		Collections.sort(prices);

		for (int j = 0; j < K; j++) {
			int price = prices.get(j);
			total += price;
		}

		System.out.println(total);
	}

} public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int K = scanner.nextInt();
		ArrayList<Integer> prices = new ArrayList<>();
		int total = 0;

		for (int i = 0; i < N; i++) {
			int p = scanner.nextInt();
			prices.add(p);
		}

		Collections.sort(prices);

		for (int j = 0; j < K; j++) {
			int price = prices.get(j);
			total += price;
		}

		System.out.println(total);
	}

} Main
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int K = scanner.nextInt();
		ArrayList<Integer> prices = new ArrayList<>();
		int total = 0;

		for (int i = 0; i < N; i++) {
			int p = scanner.nextInt();
			prices.add(p);
		}

		Collections.sort(prices);

		for (int j = 0; j < K; j++) {
			int price = prices.get(j);
			total += price;
		}

		System.out.println(total);
	}

}