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

public class Main {
	public static void main(String[] args){
		try(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++ ) {
				int p = sc.nextInt();
				pq.add(p);
			}
			
			int sum = 0;
			for(int i = 0 ; i < k ; i++ ) {
				sum += pq.remove();
			}
			
			System.out.println(sum);
			
		}
	}

} import java.util.PriorityQueue; PriorityQueue java.util import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args){
		try(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++ ) {
				int p = sc.nextInt();
				pq.add(p);
			}
			
			int sum = 0;
			for(int i = 0 ; i < k ; i++ ) {
				sum += pq.remove();
			}
			
			System.out.println(sum);
			
		}
	}

} Main public static void main(String[] args){
		try(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++ ) {
				int p = sc.nextInt();
				pq.add(p);
			}
			
			int sum = 0;
			for(int i = 0 ; i < k ; i++ ) {
				sum += pq.remove();
			}
			
			System.out.println(sum);
			
		}
	} main {
		try(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++ ) {
				int p = sc.nextInt();
				pq.add(p);
			}
			
			int sum = 0;
			for(int i = 0 ; i < k ; i++ ) {
				sum += pq.remove();
			}
			
			System.out.println(sum);
			
		}
	} try(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++ ) {
				int p = sc.nextInt();
				pq.add(p);
			}
			
			int sum = 0;
			for(int i = 0 ; i < k ; i++ ) {
				sum += pq.remove();
			}
			
			System.out.println(sum);
			
		} {
			
			int n = sc.nextInt();
			int k = sc.nextInt();
		
			PriorityQueue<Integer> pq = new PriorityQueue<>();
			
			for(int i = 0 ; i < n ; i++ ) {
				int p = sc.nextInt();
				pq.add(p);
			}
			
			int sum = 0;
			for(int i = 0 ; i < k ; i++ ) {
				sum += pq.remove();
			}
			
			System.out.println(sum);
			
		} Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) 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++ ) {
				int p = sc.nextInt();
				pq.add(p);
			} int i = 0 ; int i = 0 ; i 0 i < n i n i++ i++ i {
				int p = sc.nextInt();
				pq.add(p);
			} {
				int p = sc.nextInt();
				pq.add(p);
			} int p = sc.nextInt(); p sc.nextInt() sc.nextInt sc pq.add(p) pq.add pq p int sum = 0; sum 0 for(int i = 0 ; i < k ; i++ ) {
				sum += pq.remove();
			} int i = 0 ; int i = 0 ; i 0 i < k i k i++ i++ i {
				sum += pq.remove();
			} {
				sum += pq.remove();
			} sum += pq.remove() sum pq.remove() pq.remove pq System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {
	public static void main(String[] args){
		try(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++ ) {
				int p = sc.nextInt();
				pq.add(p);
			}
			
			int sum = 0;
			for(int i = 0 ; i < k ; i++ ) {
				sum += pq.remove();
			}
			
			System.out.println(sum);
			
		}
	}

} public class Main {
	public static void main(String[] args){
		try(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++ ) {
				int p = sc.nextInt();
				pq.add(p);
			}
			
			int sum = 0;
			for(int i = 0 ; i < k ; i++ ) {
				sum += pq.remove();
			}
			
			System.out.println(sum);
			
		}
	}

} Main
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		try(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++ ) {
				int p = sc.nextInt();
				pq.add(p);
			}
			
			int sum = 0;
			for(int i = 0 ; i < k ; i++ ) {
				sum += pq.remove();
			}
			
			System.out.println(sum);
			
		}
	}

}