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

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

		int N = sc.nextInt();
		int K = sc.nextInt();
		int sum = 0;

		List<Integer> cost = new ArrayList<>();

		for(int i=0;i<N;i++) cost.add(sc.nextInt());

		Collections.sort(cost);

		for(int i=0;i<K;i++) sum+=cost.get(i);

		System.out.println(sum);
	}

} import java.io.IOException; IOException java.io 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 public class Main {
	public static void main(String[] args) throws IOException {
    	Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int K = sc.nextInt();
		int sum = 0;

		List<Integer> cost = new ArrayList<>();

		for(int i=0;i<N;i++) cost.add(sc.nextInt());

		Collections.sort(cost);

		for(int i=0;i<K;i++) sum+=cost.get(i);

		System.out.println(sum);
	}

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

		int N = sc.nextInt();
		int K = sc.nextInt();
		int sum = 0;

		List<Integer> cost = new ArrayList<>();

		for(int i=0;i<N;i++) cost.add(sc.nextInt());

		Collections.sort(cost);

		for(int i=0;i<K;i++) sum+=cost.get(i);

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

		int N = sc.nextInt();
		int K = sc.nextInt();
		int sum = 0;

		List<Integer> cost = new ArrayList<>();

		for(int i=0;i<N;i++) cost.add(sc.nextInt());

		Collections.sort(cost);

		for(int i=0;i<K;i++) sum+=cost.get(i);

		System.out.println(sum);
	} 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 int sum = 0; sum 0 List<Integer> cost = new ArrayList<>(); cost new ArrayList<>() for(int i=0;i<N;i++) cost.add(sc.nextInt()); int i=0; int i=0; i 0 i<N i N i++ i++ i cost.add(sc.nextInt()); cost.add(sc.nextInt()) cost.add cost sc.nextInt() sc.nextInt sc Collections.sort(cost) Collections.sort Collections cost for(int i=0;i<K;i++) sum+=cost.get(i); int i=0; int i=0; i 0 i<K i K i++ i++ i sum+=cost.get(i); sum+=cost.get(i) sum cost.get(i) cost.get cost i 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) throws IOException {
    	Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int K = sc.nextInt();
		int sum = 0;

		List<Integer> cost = new ArrayList<>();

		for(int i=0;i<N;i++) cost.add(sc.nextInt());

		Collections.sort(cost);

		for(int i=0;i<K;i++) sum+=cost.get(i);

		System.out.println(sum);
	}

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

		int N = sc.nextInt();
		int K = sc.nextInt();
		int sum = 0;

		List<Integer> cost = new ArrayList<>();

		for(int i=0;i<N;i++) cost.add(sc.nextInt());

		Collections.sort(cost);

		for(int i=0;i<K;i++) sum+=cost.get(i);

		System.out.println(sum);
	}

} Main
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

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

		int N = sc.nextInt();
		int K = sc.nextInt();
		int sum = 0;

		List<Integer> cost = new ArrayList<>();

		for(int i=0;i<N;i++) cost.add(sc.nextInt());

		Collections.sort(cost);

		for(int i=0;i<K;i++) sum+=cost.get(i);

		System.out.println(sum);
	}

}