import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int K = stdIn.nextInt();
		int[] price = new int[N];
		int total = 0;

		for(int i=0;i<N;i++) {
			price[i] = stdIn.nextInt();
		}

		Arrays.sort(price);

		for(int i=0;i<K;i++) {
			total += price[i];
		}

		System.out.println(total);
		stdIn.close();
	}

} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int K = stdIn.nextInt();
		int[] price = new int[N];
		int total = 0;

		for(int i=0;i<N;i++) {
			price[i] = stdIn.nextInt();
		}

		Arrays.sort(price);

		for(int i=0;i<K;i++) {
			total += price[i];
		}

		System.out.println(total);
		stdIn.close();
	}

} Main public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int K = stdIn.nextInt();
		int[] price = new int[N];
		int total = 0;

		for(int i=0;i<N;i++) {
			price[i] = stdIn.nextInt();
		}

		Arrays.sort(price);

		for(int i=0;i<K;i++) {
			total += price[i];
		}

		System.out.println(total);
		stdIn.close();
	} main {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int K = stdIn.nextInt();
		int[] price = new int[N];
		int total = 0;

		for(int i=0;i<N;i++) {
			price[i] = stdIn.nextInt();
		}

		Arrays.sort(price);

		for(int i=0;i<K;i++) {
			total += price[i];
		}

		System.out.println(total);
		stdIn.close();
	} Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) int N = stdIn.nextInt(); N stdIn.nextInt() stdIn.nextInt stdIn int K = stdIn.nextInt(); K stdIn.nextInt() stdIn.nextInt stdIn int[] price = new int[N]; price new int[N] N int total = 0; total 0 for(int i=0;i<N;i++) {
			price[i] = stdIn.nextInt();
		} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			price[i] = stdIn.nextInt();
		} {
			price[i] = stdIn.nextInt();
		} price[i] = stdIn.nextInt() price[i] price i stdIn.nextInt() stdIn.nextInt stdIn Arrays.sort(price) Arrays.sort Arrays price for(int i=0;i<K;i++) {
			total += price[i];
		} int i=0; int i=0; i 0 i<K i K i++ i++ i {
			total += price[i];
		} {
			total += price[i];
		} total += price[i] total price[i] price i System.out.println(total) System.out.println System.out System System.out total stdIn.close() stdIn.close stdIn String[] args args public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int K = stdIn.nextInt();
		int[] price = new int[N];
		int total = 0;

		for(int i=0;i<N;i++) {
			price[i] = stdIn.nextInt();
		}

		Arrays.sort(price);

		for(int i=0;i<K;i++) {
			total += price[i];
		}

		System.out.println(total);
		stdIn.close();
	}

} public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int K = stdIn.nextInt();
		int[] price = new int[N];
		int total = 0;

		for(int i=0;i<N;i++) {
			price[i] = stdIn.nextInt();
		}

		Arrays.sort(price);

		for(int i=0;i<K;i++) {
			total += price[i];
		}

		System.out.println(total);
		stdIn.close();
	}

} Main
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int K = stdIn.nextInt();
		int[] price = new int[N];
		int total = 0;

		for(int i=0;i<N;i++) {
			price[i] = stdIn.nextInt();
		}

		Arrays.sort(price);

		for(int i=0;i<K;i++) {
			total += price[i];
		}

		System.out.println(total);
		stdIn.close();
	}

}