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

class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = Integer.parseInt(sc.next());
		int K = Integer.parseInt(sc.next());
		List<Integer> arr = new ArrayList();
		for(int i=0;i<N;i++) {
			arr.add(Integer.parseInt(sc.next()));
		}
		Collections.sort(arr);

		int totalMin =0;
		for(int i=0;i<K;i++) {
			totalMin+= arr.get(i);
		}

		System.out.println(totalMin);
	}
} import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util import java.util.List; List 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 = Integer.parseInt(sc.next());
		int K = Integer.parseInt(sc.next());
		List<Integer> arr = new ArrayList();
		for(int i=0;i<N;i++) {
			arr.add(Integer.parseInt(sc.next()));
		}
		Collections.sort(arr);

		int totalMin =0;
		for(int i=0;i<K;i++) {
			totalMin+= arr.get(i);
		}

		System.out.println(totalMin);
	}
} Main public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = Integer.parseInt(sc.next());
		int K = Integer.parseInt(sc.next());
		List<Integer> arr = new ArrayList();
		for(int i=0;i<N;i++) {
			arr.add(Integer.parseInt(sc.next()));
		}
		Collections.sort(arr);

		int totalMin =0;
		for(int i=0;i<K;i++) {
			totalMin+= arr.get(i);
		}

		System.out.println(totalMin);
	} main {

		Scanner sc = new Scanner(System.in);

		int N = Integer.parseInt(sc.next());
		int K = Integer.parseInt(sc.next());
		List<Integer> arr = new ArrayList();
		for(int i=0;i<N;i++) {
			arr.add(Integer.parseInt(sc.next()));
		}
		Collections.sort(arr);

		int totalMin =0;
		for(int i=0;i<K;i++) {
			totalMin+= arr.get(i);
		}

		System.out.println(totalMin);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = Integer.parseInt(sc.next()); N Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int K = Integer.parseInt(sc.next()); K Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc List<Integer> arr = new ArrayList(); arr new ArrayList() for(int i=0;i<N;i++) {
			arr.add(Integer.parseInt(sc.next()));
		} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			arr.add(Integer.parseInt(sc.next()));
		} {
			arr.add(Integer.parseInt(sc.next()));
		} arr.add(Integer.parseInt(sc.next())) arr.add arr Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc Collections.sort(arr) Collections.sort Collections arr int totalMin =0; totalMin 0 for(int i=0;i<K;i++) {
			totalMin+= arr.get(i);
		} int i=0; int i=0; i 0 i<K i K i++ i++ i {
			totalMin+= arr.get(i);
		} {
			totalMin+= arr.get(i);
		} totalMin+= arr.get(i) totalMin arr.get(i) arr.get arr i System.out.println(totalMin) System.out.println System.out System System.out totalMin String[] args args
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = Integer.parseInt(sc.next());
		int K = Integer.parseInt(sc.next());
		List<Integer> arr = new ArrayList();
		for(int i=0;i<N;i++) {
			arr.add(Integer.parseInt(sc.next()));
		}
		Collections.sort(arr);

		int totalMin =0;
		for(int i=0;i<K;i++) {
			totalMin+= arr.get(i);
		}

		System.out.println(totalMin);
	}
}
