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