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

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		int k = scn.nextInt();
		int[] arr = new int[N];
		for (int i = 0; i < N; i++) {
			arr[i] = scn.nextInt();
		}
		Arrays.parallelSort(arr);
		int ans = 0;
		for (int i = 0; i < k; i++) {
			ans = ans + arr[i];
		}
		System.out.println(ans);

	}

} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		int k = scn.nextInt();
		int[] arr = new int[N];
		for (int i = 0; i < N; i++) {
			arr[i] = scn.nextInt();
		}
		Arrays.parallelSort(arr);
		int ans = 0;
		for (int i = 0; i < k; i++) {
			ans = ans + arr[i];
		}
		System.out.println(ans);

	}

} Main public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		int k = scn.nextInt();
		int[] arr = new int[N];
		for (int i = 0; i < N; i++) {
			arr[i] = scn.nextInt();
		}
		Arrays.parallelSort(arr);
		int ans = 0;
		for (int i = 0; i < k; i++) {
			ans = ans + arr[i];
		}
		System.out.println(ans);

	} main {
		// TODO Auto-generated method stub
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		int k = scn.nextInt();
		int[] arr = new int[N];
		for (int i = 0; i < N; i++) {
			arr[i] = scn.nextInt();
		}
		Arrays.parallelSort(arr);
		int ans = 0;
		for (int i = 0; i < k; i++) {
			ans = ans + arr[i];
		}
		System.out.println(ans);

	} Scanner scn = new Scanner(System.in); scn new Scanner(System.in) int N = scn.nextInt(); N scn.nextInt() scn.nextInt scn int k = scn.nextInt(); k scn.nextInt() scn.nextInt scn int[] arr = new int[N]; arr new int[N] N for (int i = 0; i < N; i++) {
			arr[i] = scn.nextInt();
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			arr[i] = scn.nextInt();
		} {
			arr[i] = scn.nextInt();
		} arr[i] = scn.nextInt() arr[i] arr i scn.nextInt() scn.nextInt scn Arrays.parallelSort(arr) Arrays.parallelSort Arrays arr int ans = 0; ans 0 for (int i = 0; i < k; i++) {
			ans = ans + arr[i];
		} int i = 0; int i = 0; i 0 i < k i k i++ i++ i {
			ans = ans + arr[i];
		} {
			ans = ans + arr[i];
		} ans = ans + arr[i] ans ans + arr[i] ans arr[i] arr i System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		int k = scn.nextInt();
		int[] arr = new int[N];
		for (int i = 0; i < N; i++) {
			arr[i] = scn.nextInt();
		}
		Arrays.parallelSort(arr);
		int ans = 0;
		for (int i = 0; i < k; i++) {
			ans = ans + arr[i];
		}
		System.out.println(ans);

	}

} public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		int k = scn.nextInt();
		int[] arr = new int[N];
		for (int i = 0; i < N; i++) {
			arr[i] = scn.nextInt();
		}
		Arrays.parallelSort(arr);
		int ans = 0;
		for (int i = 0; i < k; i++) {
			ans = ans + arr[i];
		}
		System.out.println(ans);

	}

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

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		int k = scn.nextInt();
		int[] arr = new int[N];
		for (int i = 0; i < N; i++) {
			arr[i] = scn.nextInt();
		}
		Arrays.parallelSort(arr);
		int ans = 0;
		for (int i = 0; i < k; i++) {
			ans = ans + arr[i];
		}
		System.out.println(ans);

	}

}
