import 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[] data = new int[N];
		for (int i=0;i<N;i++) {
			data[i] = sc.nextInt();
		}
		int result = 0;
		for(int i=0;i<data.length-1;i++){
			for(int j=data.length-1;j>i;j--){
				if(data[j]<data[j-1]){
					int t=data[j];
					data[j]=data[j-1];
					data[j-1]=t;
				}
			}
		}		
		for (int i=0;i<K;i++) {
			result = result + data[i];
		}
		System.out.println(result);
		sc.close();
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] data = new int[N];
		for (int i=0;i<N;i++) {
			data[i] = sc.nextInt();
		}
		int result = 0;
		for(int i=0;i<data.length-1;i++){
			for(int j=data.length-1;j>i;j--){
				if(data[j]<data[j-1]){
					int t=data[j];
					data[j]=data[j-1];
					data[j-1]=t;
				}
			}
		}		
		for (int i=0;i<K;i++) {
			result = result + data[i];
		}
		System.out.println(result);
		sc.close();
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] data = new int[N];
		for (int i=0;i<N;i++) {
			data[i] = sc.nextInt();
		}
		int result = 0;
		for(int i=0;i<data.length-1;i++){
			for(int j=data.length-1;j>i;j--){
				if(data[j]<data[j-1]){
					int t=data[j];
					data[j]=data[j-1];
					data[j-1]=t;
				}
			}
		}		
		for (int i=0;i<K;i++) {
			result = result + data[i];
		}
		System.out.println(result);
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] data = new int[N];
		for (int i=0;i<N;i++) {
			data[i] = sc.nextInt();
		}
		int result = 0;
		for(int i=0;i<data.length-1;i++){
			for(int j=data.length-1;j>i;j--){
				if(data[j]<data[j-1]){
					int t=data[j];
					data[j]=data[j-1];
					data[j-1]=t;
				}
			}
		}		
		for (int i=0;i<K;i++) {
			result = result + data[i];
		}
		System.out.println(result);
		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[] data = new int[N]; data new int[N] N for (int i=0;i<N;i++) {
			data[i] = sc.nextInt();
		} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			data[i] = sc.nextInt();
		} {
			data[i] = sc.nextInt();
		} data[i] = sc.nextInt() data[i] data i sc.nextInt() sc.nextInt sc int result = 0; result 0 for(int i=0;i<data.length-1;i++){
			for(int j=data.length-1;j>i;j--){
				if(data[j]<data[j-1]){
					int t=data[j];
					data[j]=data[j-1];
					data[j-1]=t;
				}
			}
		} int i=0; int i=0; i 0 i<data.length-1 i data.length-1 data.length data data.length 1 i++ i++ i {
			for(int j=data.length-1;j>i;j--){
				if(data[j]<data[j-1]){
					int t=data[j];
					data[j]=data[j-1];
					data[j-1]=t;
				}
			}
		} {
			for(int j=data.length-1;j>i;j--){
				if(data[j]<data[j-1]){
					int t=data[j];
					data[j]=data[j-1];
					data[j-1]=t;
				}
			}
		} for(int j=data.length-1;j>i;j--){
				if(data[j]<data[j-1]){
					int t=data[j];
					data[j]=data[j-1];
					data[j-1]=t;
				}
			} int j=data.length-1; int j=data.length-1; j data.length-1 data.length data data.length 1 j>i j i j-- j-- j {
				if(data[j]<data[j-1]){
					int t=data[j];
					data[j]=data[j-1];
					data[j-1]=t;
				}
			} {
				if(data[j]<data[j-1]){
					int t=data[j];
					data[j]=data[j-1];
					data[j-1]=t;
				}
			} if(data[j]<data[j-1]){
					int t=data[j];
					data[j]=data[j-1];
					data[j-1]=t;
				} data[j]<data[j-1] data[j] data j data[j-1] data j-1 j 1 {
					int t=data[j];
					data[j]=data[j-1];
					data[j-1]=t;
				} int t=data[j]; t data[j] data j data[j]=data[j-1] data[j] data j data[j-1] data j-1 j 1 data[j-1]=t data[j-1] data j-1 j 1 t for (int i=0;i<K;i++) {
			result = result + data[i];
		} int i=0; int i=0; i 0 i<K i K i++ i++ i {
			result = result + data[i];
		} {
			result = result + data[i];
		} result = result + data[i] result result + data[i] result data[i] data i System.out.println(result) System.out.println System.out System System.out result 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[] data = new int[N];
		for (int i=0;i<N;i++) {
			data[i] = sc.nextInt();
		}
		int result = 0;
		for(int i=0;i<data.length-1;i++){
			for(int j=data.length-1;j>i;j--){
				if(data[j]<data[j-1]){
					int t=data[j];
					data[j]=data[j-1];
					data[j-1]=t;
				}
			}
		}		
		for (int i=0;i<K;i++) {
			result = result + data[i];
		}
		System.out.println(result);
		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[] data = new int[N];
		for (int i=0;i<N;i++) {
			data[i] = sc.nextInt();
		}
		int result = 0;
		for(int i=0;i<data.length-1;i++){
			for(int j=data.length-1;j>i;j--){
				if(data[j]<data[j-1]){
					int t=data[j];
					data[j]=data[j-1];
					data[j-1]=t;
				}
			}
		}		
		for (int i=0;i<K;i++) {
			result = result + data[i];
		}
		System.out.println(result);
		sc.close();
	}
} Main
import 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[] data = new int[N];
		for (int i=0;i<N;i++) {
			data[i] = sc.nextInt();
		}
		int result = 0;
		for(int i=0;i<data.length-1;i++){
			for(int j=data.length-1;j>i;j--){
				if(data[j]<data[j-1]){
					int t=data[j];
					data[j]=data[j-1];
					data[j-1]=t;
				}
			}
		}		
		for (int i=0;i<K;i++) {
			result = result + data[i];
		}
		System.out.println(result);
		sc.close();
	}
}