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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int wa,tuginoSaidai,hozon;
		wa = 0;
		final int KOSU = N;
		int[] kakaku = new int[KOSU];
		int[] narabi = new int[KOSU]; 
		for (int i=0;i<KOSU;i++) {
			kakaku[i] = sc.nextInt();
		}
		Arrays.sort(kakaku);
		for(int i=0;i<K;i++) {
			wa = wa +kakaku[i];
		}
		System.out.println(wa);
		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 N = sc.nextInt();
		int K = sc.nextInt();
		int wa,tuginoSaidai,hozon;
		wa = 0;
		final int KOSU = N;
		int[] kakaku = new int[KOSU];
		int[] narabi = new int[KOSU]; 
		for (int i=0;i<KOSU;i++) {
			kakaku[i] = sc.nextInt();
		}
		Arrays.sort(kakaku);
		for(int i=0;i<K;i++) {
			wa = wa +kakaku[i];
		}
		System.out.println(wa);
		sc.close();
	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int wa,tuginoSaidai,hozon;
		wa = 0;
		final int KOSU = N;
		int[] kakaku = new int[KOSU];
		int[] narabi = new int[KOSU]; 
		for (int i=0;i<KOSU;i++) {
			kakaku[i] = sc.nextInt();
		}
		Arrays.sort(kakaku);
		for(int i=0;i<K;i++) {
			wa = wa +kakaku[i];
		}
		System.out.println(wa);
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int wa,tuginoSaidai,hozon;
		wa = 0;
		final int KOSU = N;
		int[] kakaku = new int[KOSU];
		int[] narabi = new int[KOSU]; 
		for (int i=0;i<KOSU;i++) {
			kakaku[i] = sc.nextInt();
		}
		Arrays.sort(kakaku);
		for(int i=0;i<K;i++) {
			wa = wa +kakaku[i];
		}
		System.out.println(wa);
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int K = sc.nextInt(); K sc.nextInt() sc.nextInt sc int wa wa tuginoSaidai tuginoSaidai hozon; hozon wa = 0 wa 0 final int KOSU = N; KOSU N int[] kakaku = new int[KOSU]; kakaku new int[KOSU] KOSU int[] narabi = new int[KOSU]; narabi new int[KOSU] KOSU for (int i=0;i<KOSU;i++) {
			kakaku[i] = sc.nextInt();
		} int i=0; int i=0; i 0 i<KOSU i KOSU i++ i++ i {
			kakaku[i] = sc.nextInt();
		} {
			kakaku[i] = sc.nextInt();
		} kakaku[i] = sc.nextInt() kakaku[i] kakaku i sc.nextInt() sc.nextInt sc Arrays.sort(kakaku) Arrays.sort Arrays kakaku for(int i=0;i<K;i++) {
			wa = wa +kakaku[i];
		} int i=0; int i=0; i 0 i<K i K i++ i++ i {
			wa = wa +kakaku[i];
		} {
			wa = wa +kakaku[i];
		} wa = wa +kakaku[i] wa wa +kakaku[i] wa kakaku[i] kakaku i System.out.println(wa) System.out.println System.out System System.out wa sc.close() sc.close sc String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int wa,tuginoSaidai,hozon;
		wa = 0;
		final int KOSU = N;
		int[] kakaku = new int[KOSU];
		int[] narabi = new int[KOSU]; 
		for (int i=0;i<KOSU;i++) {
			kakaku[i] = sc.nextInt();
		}
		Arrays.sort(kakaku);
		for(int i=0;i<K;i++) {
			wa = wa +kakaku[i];
		}
		System.out.println(wa);
		sc.close();
	}

} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int wa,tuginoSaidai,hozon;
		wa = 0;
		final int KOSU = N;
		int[] kakaku = new int[KOSU];
		int[] narabi = new int[KOSU]; 
		for (int i=0;i<KOSU;i++) {
			kakaku[i] = sc.nextInt();
		}
		Arrays.sort(kakaku);
		for(int i=0;i<K;i++) {
			wa = wa +kakaku[i];
		}
		System.out.println(wa);
		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 N = sc.nextInt();
		int K = sc.nextInt();
		int wa,tuginoSaidai,hozon;
		wa = 0;
		final int KOSU = N;
		int[] kakaku = new int[KOSU];
		int[] narabi = new int[KOSU]; 
		for (int i=0;i<KOSU;i++) {
			kakaku[i] = sc.nextInt();
		}
		Arrays.sort(kakaku);
		for(int i=0;i<K;i++) {
			wa = wa +kakaku[i];
		}
		System.out.println(wa);
		sc.close();
	}

}