import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		PriorityQueue<Short> pq = new PriorityQueue<Short>();
		short N = Short.parseShort(st.nextToken());
		short T = Short.parseShort(st.nextToken());
		st = new StringTokenizer(br.readLine());
		short p;
		for (short i = 0; i < N; i++) {
			p = Short.parseShort(st.nextToken());
			pq.add(p);
		}
		int sum = 0;
		for (short i = 0; i < T; i++) {
			sum += pq.poll();
		}
		System.out.print(sum);
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.PriorityQueue; PriorityQueue 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));
		StringTokenizer st = new StringTokenizer(br.readLine());
		PriorityQueue<Short> pq = new PriorityQueue<Short>();
		short N = Short.parseShort(st.nextToken());
		short T = Short.parseShort(st.nextToken());
		st = new StringTokenizer(br.readLine());
		short p;
		for (short i = 0; i < N; i++) {
			p = Short.parseShort(st.nextToken());
			pq.add(p);
		}
		int sum = 0;
		for (short i = 0; i < T; i++) {
			sum += pq.poll();
		}
		System.out.print(sum);
	}
} Main public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		PriorityQueue<Short> pq = new PriorityQueue<Short>();
		short N = Short.parseShort(st.nextToken());
		short T = Short.parseShort(st.nextToken());
		st = new StringTokenizer(br.readLine());
		short p;
		for (short i = 0; i < N; i++) {
			p = Short.parseShort(st.nextToken());
			pq.add(p);
		}
		int sum = 0;
		for (short i = 0; i < T; i++) {
			sum += pq.poll();
		}
		System.out.print(sum);
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		PriorityQueue<Short> pq = new PriorityQueue<Short>();
		short N = Short.parseShort(st.nextToken());
		short T = Short.parseShort(st.nextToken());
		st = new StringTokenizer(br.readLine());
		short p;
		for (short i = 0; i < N; i++) {
			p = Short.parseShort(st.nextToken());
			pq.add(p);
		}
		int sum = 0;
		for (short i = 0; i < T; i++) {
			sum += pq.poll();
		}
		System.out.print(sum);
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) StringTokenizer st = new StringTokenizer(br.readLine()); st new StringTokenizer(br.readLine()) PriorityQueue<Short> pq = new PriorityQueue<Short>(); pq new PriorityQueue<Short>() short N = Short.parseShort(st.nextToken()); N Short.parseShort(st.nextToken()) Short.parseShort Short st.nextToken() st.nextToken st short T = Short.parseShort(st.nextToken()); T Short.parseShort(st.nextToken()) Short.parseShort Short st.nextToken() st.nextToken st st = new StringTokenizer(br.readLine()) st new StringTokenizer(br.readLine()) short p; p for (short i = 0; i < N; i++) {
			p = Short.parseShort(st.nextToken());
			pq.add(p);
		} short i = 0; short i = 0; i 0 i < N i N i++ i++ i {
			p = Short.parseShort(st.nextToken());
			pq.add(p);
		} {
			p = Short.parseShort(st.nextToken());
			pq.add(p);
		} p = Short.parseShort(st.nextToken()) p Short.parseShort(st.nextToken()) Short.parseShort Short st.nextToken() st.nextToken st pq.add(p) pq.add pq p int sum = 0; sum 0 for (short i = 0; i < T; i++) {
			sum += pq.poll();
		} short i = 0; short i = 0; i 0 i < T i T i++ i++ i {
			sum += pq.poll();
		} {
			sum += pq.poll();
		} sum += pq.poll() sum pq.poll() pq.poll pq System.out.print(sum) System.out.print System.out System System.out sum String[] args args public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		PriorityQueue<Short> pq = new PriorityQueue<Short>();
		short N = Short.parseShort(st.nextToken());
		short T = Short.parseShort(st.nextToken());
		st = new StringTokenizer(br.readLine());
		short p;
		for (short i = 0; i < N; i++) {
			p = Short.parseShort(st.nextToken());
			pq.add(p);
		}
		int sum = 0;
		for (short i = 0; i < T; i++) {
			sum += pq.poll();
		}
		System.out.print(sum);
	}
} public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		PriorityQueue<Short> pq = new PriorityQueue<Short>();
		short N = Short.parseShort(st.nextToken());
		short T = Short.parseShort(st.nextToken());
		st = new StringTokenizer(br.readLine());
		short p;
		for (short i = 0; i < N; i++) {
			p = Short.parseShort(st.nextToken());
			pq.add(p);
		}
		int sum = 0;
		for (short i = 0; i < T; i++) {
			sum += pq.poll();
		}
		System.out.print(sum);
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		PriorityQueue<Short> pq = new PriorityQueue<Short>();
		short N = Short.parseShort(st.nextToken());
		short T = Short.parseShort(st.nextToken());
		st = new StringTokenizer(br.readLine());
		short p;
		for (short i = 0; i < N; i++) {
			p = Short.parseShort(st.nextToken());
			pq.add(p);
		}
		int sum = 0;
		for (short i = 0; i < T; i++) {
			sum += pq.poll();
		}
		System.out.print(sum);
	}
}
