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

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int k = scan.nextInt();
		Integer a[] = new Integer[n];

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

		Arrays.sort(a);

		int total = 0;

		for(int i=0;i<k;i++) {
			total = total + a[i];
		}
		System.out.println(total);

	}

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

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int k = scan.nextInt();
		Integer a[] = new Integer[n];

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

		Arrays.sort(a);

		int total = 0;

		for(int i=0;i<k;i++) {
			total = total + a[i];
		}
		System.out.println(total);

	}

} Main public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int k = scan.nextInt();
		Integer a[] = new Integer[n];

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

		Arrays.sort(a);

		int total = 0;

		for(int i=0;i<k;i++) {
			total = total + a[i];
		}
		System.out.println(total);

	} main {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int k = scan.nextInt();
		Integer a[] = new Integer[n];

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

		Arrays.sort(a);

		int total = 0;

		for(int i=0;i<k;i++) {
			total = total + a[i];
		}
		System.out.println(total);

	} 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 Integer a[] = new Integer[n]; a new Integer[n] n for(int i=0;i<n;i++) {
			a[i] = scan.nextInt();
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			a[i] = scan.nextInt();
		} {
			a[i] = scan.nextInt();
		} a[i] = scan.nextInt() a[i] a i scan.nextInt() scan.nextInt scan Arrays.sort(a) Arrays.sort Arrays a int total = 0; total 0 for(int i=0;i<k;i++) {
			total = total + a[i];
		} int i=0; int i=0; i 0 i<k i k i++ i++ i {
			total = total + a[i];
		} {
			total = total + a[i];
		} total = total + a[i] total total + a[i] total a[i] a i System.out.println(total) System.out.println System.out System System.out total String[] args args public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int k = scan.nextInt();
		Integer a[] = new Integer[n];

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

		Arrays.sort(a);

		int total = 0;

		for(int i=0;i<k;i++) {
			total = total + a[i];
		}
		System.out.println(total);

	}

} public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int k = scan.nextInt();
		Integer a[] = new Integer[n];

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

		Arrays.sort(a);

		int total = 0;

		for(int i=0;i<k;i++) {
			total = total + a[i];
		}
		System.out.println(total);

	}

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

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int k = scan.nextInt();
		Integer a[] = new Integer[n];

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

		Arrays.sort(a);

		int total = 0;

		for(int i=0;i<k;i++) {
			total = total + a[i];
		}
		System.out.println(total);

	}

}
