import java.util.*;

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int N  = keyboard.nextInt();
		int K  = keyboard.nextInt();
		int[] p = new int[N];
		
		for(int i = 0; i < N ; i++) {
			p[i] = keyboard.nextInt();
		}
		
		Arrays.sort(p);
		int ans = 0;
		
		for(int j = 0; j < K; j++) {
			ans += p[j];
		}
		
		System.out.println(ans);
		keyboard.close();	
	}
} import java.util.*; util.* java public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int N  = keyboard.nextInt();
		int K  = keyboard.nextInt();
		int[] p = new int[N];
		
		for(int i = 0; i < N ; i++) {
			p[i] = keyboard.nextInt();
		}
		
		Arrays.sort(p);
		int ans = 0;
		
		for(int j = 0; j < K; j++) {
			ans += p[j];
		}
		
		System.out.println(ans);
		keyboard.close();	
	}
} Main public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int N  = keyboard.nextInt();
		int K  = keyboard.nextInt();
		int[] p = new int[N];
		
		for(int i = 0; i < N ; i++) {
			p[i] = keyboard.nextInt();
		}
		
		Arrays.sort(p);
		int ans = 0;
		
		for(int j = 0; j < K; j++) {
			ans += p[j];
		}
		
		System.out.println(ans);
		keyboard.close();	
	} main {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int N  = keyboard.nextInt();
		int K  = keyboard.nextInt();
		int[] p = new int[N];
		
		for(int i = 0; i < N ; i++) {
			p[i] = keyboard.nextInt();
		}
		
		Arrays.sort(p);
		int ans = 0;
		
		for(int j = 0; j < K; j++) {
			ans += p[j];
		}
		
		System.out.println(ans);
		keyboard.close();	
	} Scanner keyboard = new Scanner(System.in); keyboard new Scanner(System.in) int N  = keyboard.nextInt(); N keyboard.nextInt() keyboard.nextInt keyboard int K  = keyboard.nextInt(); K keyboard.nextInt() keyboard.nextInt keyboard int[] p = new int[N]; p new int[N] N for(int i = 0; i < N ; i++) {
			p[i] = keyboard.nextInt();
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			p[i] = keyboard.nextInt();
		} {
			p[i] = keyboard.nextInt();
		} p[i] = keyboard.nextInt() p[i] p i keyboard.nextInt() keyboard.nextInt keyboard Arrays.sort(p) Arrays.sort Arrays p int ans = 0; ans 0 for(int j = 0; j < K; j++) {
			ans += p[j];
		} int j = 0; int j = 0; j 0 j < K j K j++ j++ j {
			ans += p[j];
		} {
			ans += p[j];
		} ans += p[j] ans p[j] p j System.out.println(ans) System.out.println System.out System System.out ans keyboard.close() keyboard.close keyboard String[] args args public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int N  = keyboard.nextInt();
		int K  = keyboard.nextInt();
		int[] p = new int[N];
		
		for(int i = 0; i < N ; i++) {
			p[i] = keyboard.nextInt();
		}
		
		Arrays.sort(p);
		int ans = 0;
		
		for(int j = 0; j < K; j++) {
			ans += p[j];
		}
		
		System.out.println(ans);
		keyboard.close();	
	}
} public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int N  = keyboard.nextInt();
		int K  = keyboard.nextInt();
		int[] p = new int[N];
		
		for(int i = 0; i < N ; i++) {
			p[i] = keyboard.nextInt();
		}
		
		Arrays.sort(p);
		int ans = 0;
		
		for(int j = 0; j < K; j++) {
			ans += p[j];
		}
		
		System.out.println(ans);
		keyboard.close();	
	}
} Main
import java.util.*;

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