import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int K = scan.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		for (int i = 0; i < N; i++) {
			list.add(scan.nextInt());
		}
		int total = 0;
		for (int i = 0; i < K ; i++) {
			int price = 1001;
			int idx = 0;
			for (int j = 0; j < list.size(); j++) {
				if (price > list.get(j)) {
					price = list.get(j);
					idx = j;
				}
			}
			list.remove(idx);
			total += price;
		}
		System.out.println(total);
	}

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

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int K = scan.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		for (int i = 0; i < N; i++) {
			list.add(scan.nextInt());
		}
		int total = 0;
		for (int i = 0; i < K ; i++) {
			int price = 1001;
			int idx = 0;
			for (int j = 0; j < list.size(); j++) {
				if (price > list.get(j)) {
					price = list.get(j);
					idx = j;
				}
			}
			list.remove(idx);
			total += price;
		}
		System.out.println(total);
	}

} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int K = scan.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		for (int i = 0; i < N; i++) {
			list.add(scan.nextInt());
		}
		int total = 0;
		for (int i = 0; i < K ; i++) {
			int price = 1001;
			int idx = 0;
			for (int j = 0; j < list.size(); j++) {
				if (price > list.get(j)) {
					price = list.get(j);
					idx = j;
				}
			}
			list.remove(idx);
			total += price;
		}
		System.out.println(total);
	} main {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int K = scan.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		for (int i = 0; i < N; i++) {
			list.add(scan.nextInt());
		}
		int total = 0;
		for (int i = 0; i < K ; i++) {
			int price = 1001;
			int idx = 0;
			for (int j = 0; j < list.size(); j++) {
				if (price > list.get(j)) {
					price = list.get(j);
					idx = j;
				}
			}
			list.remove(idx);
			total += price;
		}
		System.out.println(total);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int N = scan.nextInt(); N scan.nextInt() scan.nextInt scan int K = scan.nextInt(); K scan.nextInt() scan.nextInt scan List<Integer> list = new ArrayList<Integer>(); list new ArrayList<Integer>() for (int i = 0; i < N; i++) {
			list.add(scan.nextInt());
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			list.add(scan.nextInt());
		} {
			list.add(scan.nextInt());
		} list.add(scan.nextInt()) list.add list scan.nextInt() scan.nextInt scan int total = 0; total 0 for (int i = 0; i < K ; i++) {
			int price = 1001;
			int idx = 0;
			for (int j = 0; j < list.size(); j++) {
				if (price > list.get(j)) {
					price = list.get(j);
					idx = j;
				}
			}
			list.remove(idx);
			total += price;
		} int i = 0; int i = 0; i 0 i < K i K i++ i++ i {
			int price = 1001;
			int idx = 0;
			for (int j = 0; j < list.size(); j++) {
				if (price > list.get(j)) {
					price = list.get(j);
					idx = j;
				}
			}
			list.remove(idx);
			total += price;
		} {
			int price = 1001;
			int idx = 0;
			for (int j = 0; j < list.size(); j++) {
				if (price > list.get(j)) {
					price = list.get(j);
					idx = j;
				}
			}
			list.remove(idx);
			total += price;
		} int price = 1001; price 1001 int idx = 0; idx 0 for (int j = 0; j < list.size(); j++) {
				if (price > list.get(j)) {
					price = list.get(j);
					idx = j;
				}
			} int j = 0; int j = 0; j 0 j < list.size() j list.size() list.size list j++ j++ j {
				if (price > list.get(j)) {
					price = list.get(j);
					idx = j;
				}
			} {
				if (price > list.get(j)) {
					price = list.get(j);
					idx = j;
				}
			} if (price > list.get(j)) {
					price = list.get(j);
					idx = j;
				} price > list.get(j) price list.get(j) list.get list j {
					price = list.get(j);
					idx = j;
				} price = list.get(j) price list.get(j) list.get list j idx = j idx j list.remove(idx) list.remove list idx 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) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int K = scan.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		for (int i = 0; i < N; i++) {
			list.add(scan.nextInt());
		}
		int total = 0;
		for (int i = 0; i < K ; i++) {
			int price = 1001;
			int idx = 0;
			for (int j = 0; j < list.size(); j++) {
				if (price > list.get(j)) {
					price = list.get(j);
					idx = j;
				}
			}
			list.remove(idx);
			total += price;
		}
		System.out.println(total);
	}

} public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int K = scan.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		for (int i = 0; i < N; i++) {
			list.add(scan.nextInt());
		}
		int total = 0;
		for (int i = 0; i < K ; i++) {
			int price = 1001;
			int idx = 0;
			for (int j = 0; j < list.size(); j++) {
				if (price > list.get(j)) {
					price = list.get(j);
					idx = j;
				}
			}
			list.remove(idx);
			total += price;
		}
		System.out.println(total);
	}

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

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int K = scan.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		for (int i = 0; i < N; i++) {
			list.add(scan.nextInt());
		}
		int total = 0;
		for (int i = 0; i < K ; i++) {
			int price = 1001;
			int idx = 0;
			for (int j = 0; j < list.size(); j++) {
				if (price > list.get(j)) {
					price = list.get(j);
					idx = j;
				}
			}
			list.remove(idx);
			total += price;
		}
		System.out.println(total);
	}

}
