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

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int k = scan.nextInt();

		int[] nArray = new int[n];

		for (int i = 0; i < n; i++) {

			nArray[i] = scan.nextInt();
		}

		Arrays.sort(nArray);

		int answer = 0;

		for (int i = 0; i < k; i++) {

			answer += nArray[i];
		}

		println(answer);
	}

	public static void println(Object target) {
		System.out.println(target);
	}
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int k = scan.nextInt();

		int[] nArray = new int[n];

		for (int i = 0; i < n; i++) {

			nArray[i] = scan.nextInt();
		}

		Arrays.sort(nArray);

		int answer = 0;

		for (int i = 0; i < k; i++) {

			answer += nArray[i];
		}

		println(answer);
	}

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

		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int k = scan.nextInt();

		int[] nArray = new int[n];

		for (int i = 0; i < n; i++) {

			nArray[i] = scan.nextInt();
		}

		Arrays.sort(nArray);

		int answer = 0;

		for (int i = 0; i < k; i++) {

			answer += nArray[i];
		}

		println(answer);
	} main {

		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int k = scan.nextInt();

		int[] nArray = new int[n];

		for (int i = 0; i < n; i++) {

			nArray[i] = scan.nextInt();
		}

		Arrays.sort(nArray);

		int answer = 0;

		for (int i = 0; i < k; i++) {

			answer += nArray[i];
		}

		println(answer);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan int k = scan.nextInt(); k scan.nextInt() scan.nextInt scan int[] nArray = new int[n]; nArray new int[n] n for (int i = 0; i < n; i++) {

			nArray[i] = scan.nextInt();
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {

			nArray[i] = scan.nextInt();
		} {

			nArray[i] = scan.nextInt();
		} nArray[i] = scan.nextInt() nArray[i] nArray i scan.nextInt() scan.nextInt scan Arrays.sort(nArray) Arrays.sort Arrays nArray int answer = 0; answer 0 for (int i = 0; i < k; i++) {

			answer += nArray[i];
		} int i = 0; int i = 0; i 0 i < k i k i++ i++ i {

			answer += nArray[i];
		} {

			answer += nArray[i];
		} answer += nArray[i] answer nArray[i] nArray i println(answer) println answer String[] args args public static void println(Object target) {
		System.out.println(target);
	} println {
		System.out.println(target);
	} System.out.println(target) System.out.println System.out System System.out target Object target target public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int k = scan.nextInt();

		int[] nArray = new int[n];

		for (int i = 0; i < n; i++) {

			nArray[i] = scan.nextInt();
		}

		Arrays.sort(nArray);

		int answer = 0;

		for (int i = 0; i < k; i++) {

			answer += nArray[i];
		}

		println(answer);
	}

	public static void println(Object target) {
		System.out.println(target);
	}
} public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int k = scan.nextInt();

		int[] nArray = new int[n];

		for (int i = 0; i < n; i++) {

			nArray[i] = scan.nextInt();
		}

		Arrays.sort(nArray);

		int answer = 0;

		for (int i = 0; i < k; i++) {

			answer += nArray[i];
		}

		println(answer);
	}

	public static void println(Object target) {
		System.out.println(target);
	}
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int k = scan.nextInt();

		int[] nArray = new int[n];

		for (int i = 0; i < n; i++) {

			nArray[i] = scan.nextInt();
		}

		Arrays.sort(nArray);

		int answer = 0;

		for (int i = 0; i < k; i++) {

			answer += nArray[i];
		}

		println(answer);
	}

	public static void println(Object target) {
		System.out.println(target);
	}
}
