
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int K = sc.nextInt();
		
		PriorityQueue<Integer> pq = new PriorityQueue<>();

		for(int i=0; i < N; i++) {
			pq.add(sc.nextInt());
		}
		
		
		int[] p = new int[N];
		
		int j = 0;
		while(! pq.isEmpty()) {
			p[j] = pq.poll();
			j ++;
		}
		
		int total = 0;

		
		for(int i=0; i<K; i++){
			total += p[i];
		}
		
		System.out.println(total);

	}
}
 import java.util.PriorityQueue; PriorityQueue java.util import java.util.Scanner; Scanner java.util class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int K = sc.nextInt();
		
		PriorityQueue<Integer> pq = new PriorityQueue<>();

		for(int i=0; i < N; i++) {
			pq.add(sc.nextInt());
		}
		
		
		int[] p = new int[N];
		
		int j = 0;
		while(! pq.isEmpty()) {
			p[j] = pq.poll();
			j ++;
		}
		
		int total = 0;

		
		for(int i=0; i<K; i++){
			total += p[i];
		}
		
		System.out.println(total);

	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int K = sc.nextInt();
		
		PriorityQueue<Integer> pq = new PriorityQueue<>();

		for(int i=0; i < N; i++) {
			pq.add(sc.nextInt());
		}
		
		
		int[] p = new int[N];
		
		int j = 0;
		while(! pq.isEmpty()) {
			p[j] = pq.poll();
			j ++;
		}
		
		int total = 0;

		
		for(int i=0; i<K; i++){
			total += p[i];
		}
		
		System.out.println(total);

	} main {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int K = sc.nextInt();
		
		PriorityQueue<Integer> pq = new PriorityQueue<>();

		for(int i=0; i < N; i++) {
			pq.add(sc.nextInt());
		}
		
		
		int[] p = new int[N];
		
		int j = 0;
		while(! pq.isEmpty()) {
			p[j] = pq.poll();
			j ++;
		}
		
		int total = 0;

		
		for(int i=0; i<K; i++){
			total += p[i];
		}
		
		System.out.println(total);

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int K = sc.nextInt(); K sc.nextInt() sc.nextInt sc PriorityQueue<Integer> pq = new PriorityQueue<>(); pq new PriorityQueue<>() for(int i=0; i < N; i++) {
			pq.add(sc.nextInt());
		} int i=0; int i=0; i 0 i < N i N i++ i++ i {
			pq.add(sc.nextInt());
		} {
			pq.add(sc.nextInt());
		} pq.add(sc.nextInt()) pq.add pq sc.nextInt() sc.nextInt sc int[] p = new int[N]; p new int[N] N int j = 0; j 0 while(! pq.isEmpty()) {
			p[j] = pq.poll();
			j ++;
		} ! pq.isEmpty() pq.isEmpty() pq.isEmpty pq {
			p[j] = pq.poll();
			j ++;
		} p[j] = pq.poll() p[j] p j pq.poll() pq.poll pq j ++ j int total = 0; total 0 for(int i=0; i<K; i++){
			total += p[i];
		} int i=0; int i=0; i 0 i<K i K i++ i++ i {
			total += p[i];
		} {
			total += p[i];
		} total += p[i] total p[i] p i System.out.println(total) System.out.println System.out System System.out total String[] args args

import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int K = sc.nextInt();
		
		PriorityQueue<Integer> pq = new PriorityQueue<>();

		for(int i=0; i < N; i++) {
			pq.add(sc.nextInt());
		}
		
		
		int[] p = new int[N];
		
		int j = 0;
		while(! pq.isEmpty()) {
			p[j] = pq.poll();
			j ++;
		}
		
		int total = 0;

		
		for(int i=0; i<K; i++){
			total += p[i];
		}
		
		System.out.println(total);

	}
}

