import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int N[] = new int[a];
		int b = sc.nextInt();
		for (int i = 0; i < N.length; i++) {
			N[i] = sc.nextInt();
		}

		Arrays.sort(N);
		int sum = 0;


		for (int i = 0; i < b; i++) {
			sum += N[i];
		}

		System.out.println(sum);
		sc.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 sc = new Scanner(System.in);
		int a = sc.nextInt();
		int N[] = new int[a];
		int b = sc.nextInt();
		for (int i = 0; i < N.length; i++) {
			N[i] = sc.nextInt();
		}

		Arrays.sort(N);
		int sum = 0;


		for (int i = 0; i < b; i++) {
			sum += N[i];
		}

		System.out.println(sum);
		sc.close();

	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int N[] = new int[a];
		int b = sc.nextInt();
		for (int i = 0; i < N.length; i++) {
			N[i] = sc.nextInt();
		}

		Arrays.sort(N);
		int sum = 0;


		for (int i = 0; i < b; i++) {
			sum += N[i];
		}

		System.out.println(sum);
		sc.close();

	} main {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int N[] = new int[a];
		int b = sc.nextInt();
		for (int i = 0; i < N.length; i++) {
			N[i] = sc.nextInt();
		}

		Arrays.sort(N);
		int sum = 0;


		for (int i = 0; i < b; i++) {
			sum += N[i];
		}

		System.out.println(sum);
		sc.close();

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc int N[] = new int[a]; N new int[a] a int b = sc.nextInt(); b sc.nextInt() sc.nextInt sc for (int i = 0; i < N.length; i++) {
			N[i] = sc.nextInt();
		} int i = 0; int i = 0; i 0 i < N.length i N.length N N.length i++ i++ i {
			N[i] = sc.nextInt();
		} {
			N[i] = sc.nextInt();
		} N[i] = sc.nextInt() N[i] N i sc.nextInt() sc.nextInt sc Arrays.sort(N) Arrays.sort Arrays N int sum = 0; sum 0 for (int i = 0; i < b; i++) {
			sum += N[i];
		} int i = 0; int i = 0; i 0 i < b i b i++ i++ i {
			sum += N[i];
		} {
			sum += N[i];
		} sum += N[i] sum N[i] N i System.out.println(sum) System.out.println System.out System System.out sum sc.close() sc.close sc String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int N[] = new int[a];
		int b = sc.nextInt();
		for (int i = 0; i < N.length; i++) {
			N[i] = sc.nextInt();
		}

		Arrays.sort(N);
		int sum = 0;


		for (int i = 0; i < b; i++) {
			sum += N[i];
		}

		System.out.println(sum);
		sc.close();

	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int N[] = new int[a];
		int b = sc.nextInt();
		for (int i = 0; i < N.length; i++) {
			N[i] = sc.nextInt();
		}

		Arrays.sort(N);
		int sum = 0;


		for (int i = 0; i < b; i++) {
			sum += N[i];
		}

		System.out.println(sum);
		sc.close();

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int N[] = new int[a];
		int b = sc.nextInt();
		for (int i = 0; i < N.length; i++) {
			N[i] = sc.nextInt();
		}

		Arrays.sort(N);
		int sum = 0;


		for (int i = 0; i < b; i++) {
			sum += N[i];
		}

		System.out.println(sum);
		sc.close();

	}
}