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

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int K = stdIn.nextInt();
		int []p = new int[N];
		int max = 0;
		for(int a = 0; a < N; a++){
			p[a] = stdIn.nextInt();
		}
		Arrays.sort(p);
		for(int c = 0; c < K; c++){
			max += p[c];
		}
		System.out.println(max);
		stdIn.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 stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int K = stdIn.nextInt();
		int []p = new int[N];
		int max = 0;
		for(int a = 0; a < N; a++){
			p[a] = stdIn.nextInt();
		}
		Arrays.sort(p);
		for(int c = 0; c < K; c++){
			max += p[c];
		}
		System.out.println(max);
		stdIn.close();
	}
} Main public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int K = stdIn.nextInt();
		int []p = new int[N];
		int max = 0;
		for(int a = 0; a < N; a++){
			p[a] = stdIn.nextInt();
		}
		Arrays.sort(p);
		for(int c = 0; c < K; c++){
			max += p[c];
		}
		System.out.println(max);
		stdIn.close();
	} main {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int K = stdIn.nextInt();
		int []p = new int[N];
		int max = 0;
		for(int a = 0; a < N; a++){
			p[a] = stdIn.nextInt();
		}
		Arrays.sort(p);
		for(int c = 0; c < K; c++){
			max += p[c];
		}
		System.out.println(max);
		stdIn.close();
	} Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) int N = stdIn.nextInt(); N stdIn.nextInt() stdIn.nextInt stdIn int K = stdIn.nextInt(); K stdIn.nextInt() stdIn.nextInt stdIn int []p = new int[N]; p new int[N] N int max = 0; max 0 for(int a = 0; a < N; a++){
			p[a] = stdIn.nextInt();
		} int a = 0; int a = 0; a 0 a < N a N a++ a++ a {
			p[a] = stdIn.nextInt();
		} {
			p[a] = stdIn.nextInt();
		} p[a] = stdIn.nextInt() p[a] p a stdIn.nextInt() stdIn.nextInt stdIn Arrays.sort(p) Arrays.sort Arrays p for(int c = 0; c < K; c++){
			max += p[c];
		} int c = 0; int c = 0; c 0 c < K c K c++ c++ c {
			max += p[c];
		} {
			max += p[c];
		} max += p[c] max p[c] p c System.out.println(max) System.out.println System.out System System.out max stdIn.close() stdIn.close stdIn String[] args args public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int K = stdIn.nextInt();
		int []p = new int[N];
		int max = 0;
		for(int a = 0; a < N; a++){
			p[a] = stdIn.nextInt();
		}
		Arrays.sort(p);
		for(int c = 0; c < K; c++){
			max += p[c];
		}
		System.out.println(max);
		stdIn.close();
	}
} public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int K = stdIn.nextInt();
		int []p = new int[N];
		int max = 0;
		for(int a = 0; a < N; a++){
			p[a] = stdIn.nextInt();
		}
		Arrays.sort(p);
		for(int c = 0; c < K; c++){
			max += p[c];
		}
		System.out.println(max);
		stdIn.close();
	}
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int K = stdIn.nextInt();
		int []p = new int[N];
		int max = 0;
		for(int a = 0; a < N; a++){
			p[a] = stdIn.nextInt();
		}
		Arrays.sort(p);
		for(int c = 0; c < K; c++){
			max += p[c];
		}
		System.out.println(max);
		stdIn.close();
	}
}
