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

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int N = in.nextInt();
		int K = in.nextInt();
		int sum = 0;
		Integer a[] = new Integer[N];
		Integer b[] = new Integer[K];
		
		for(int i = 0;i < N;i++) {
			a[i] = in.nextInt();
		}
		
		Arrays.sort(a,Comparator.naturalOrder());
		
		for(int i = 0;i < K;i++) {
			b[i] = a[i];
		}
		
		for(int i = 0;i < K;i++) {
			sum += b[i];
		}
		
		System.out.println(sum);
	}
} import java.util.Arrays; Arrays java.util import java.util.Comparator; Comparator java.util import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int N = in.nextInt();
		int K = in.nextInt();
		int sum = 0;
		Integer a[] = new Integer[N];
		Integer b[] = new Integer[K];
		
		for(int i = 0;i < N;i++) {
			a[i] = in.nextInt();
		}
		
		Arrays.sort(a,Comparator.naturalOrder());
		
		for(int i = 0;i < K;i++) {
			b[i] = a[i];
		}
		
		for(int i = 0;i < K;i++) {
			sum += b[i];
		}
		
		System.out.println(sum);
	}
} Main public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int N = in.nextInt();
		int K = in.nextInt();
		int sum = 0;
		Integer a[] = new Integer[N];
		Integer b[] = new Integer[K];
		
		for(int i = 0;i < N;i++) {
			a[i] = in.nextInt();
		}
		
		Arrays.sort(a,Comparator.naturalOrder());
		
		for(int i = 0;i < K;i++) {
			b[i] = a[i];
		}
		
		for(int i = 0;i < K;i++) {
			sum += b[i];
		}
		
		System.out.println(sum);
	} main {
		Scanner in = new Scanner(System.in);
		
		int N = in.nextInt();
		int K = in.nextInt();
		int sum = 0;
		Integer a[] = new Integer[N];
		Integer b[] = new Integer[K];
		
		for(int i = 0;i < N;i++) {
			a[i] = in.nextInt();
		}
		
		Arrays.sort(a,Comparator.naturalOrder());
		
		for(int i = 0;i < K;i++) {
			b[i] = a[i];
		}
		
		for(int i = 0;i < K;i++) {
			sum += b[i];
		}
		
		System.out.println(sum);
	} Scanner in = new Scanner(System.in); in new Scanner(System.in) int N = in.nextInt(); N in.nextInt() in.nextInt in int K = in.nextInt(); K in.nextInt() in.nextInt in int sum = 0; sum 0 Integer a[] = new Integer[N]; a new Integer[N] N Integer b[] = new Integer[K]; b new Integer[K] K for(int i = 0;i < N;i++) {
			a[i] = in.nextInt();
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			a[i] = in.nextInt();
		} {
			a[i] = in.nextInt();
		} a[i] = in.nextInt() a[i] a i in.nextInt() in.nextInt in Arrays.sort(a,Comparator.naturalOrder()) Arrays.sort Arrays a Comparator.naturalOrder() Comparator.naturalOrder Comparator for(int i = 0;i < K;i++) {
			b[i] = a[i];
		} int i = 0; int i = 0; i 0 i < K i K i++ i++ i {
			b[i] = a[i];
		} {
			b[i] = a[i];
		} b[i] = a[i] b[i] b i a[i] a i for(int i = 0;i < K;i++) {
			sum += b[i];
		} int i = 0; int i = 0; i 0 i < K i K i++ i++ i {
			sum += b[i];
		} {
			sum += b[i];
		} sum += b[i] sum b[i] b i System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int N = in.nextInt();
		int K = in.nextInt();
		int sum = 0;
		Integer a[] = new Integer[N];
		Integer b[] = new Integer[K];
		
		for(int i = 0;i < N;i++) {
			a[i] = in.nextInt();
		}
		
		Arrays.sort(a,Comparator.naturalOrder());
		
		for(int i = 0;i < K;i++) {
			b[i] = a[i];
		}
		
		for(int i = 0;i < K;i++) {
			sum += b[i];
		}
		
		System.out.println(sum);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int N = in.nextInt();
		int K = in.nextInt();
		int sum = 0;
		Integer a[] = new Integer[N];
		Integer b[] = new Integer[K];
		
		for(int i = 0;i < N;i++) {
			a[i] = in.nextInt();
		}
		
		Arrays.sort(a,Comparator.naturalOrder());
		
		for(int i = 0;i < K;i++) {
			b[i] = a[i];
		}
		
		for(int i = 0;i < K;i++) {
			sum += b[i];
		}
		
		System.out.println(sum);
	}
} Main
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int N = in.nextInt();
		int K = in.nextInt();
		int sum = 0;
		Integer a[] = new Integer[N];
		Integer b[] = new Integer[K];
		
		for(int i = 0;i < N;i++) {
			a[i] = in.nextInt();
		}
		
		Arrays.sort(a,Comparator.naturalOrder());
		
		for(int i = 0;i < K;i++) {
			b[i] = a[i];
		}
		
		for(int i = 0;i < K;i++) {
			sum += b[i];
		}
		
		System.out.println(sum);
	}
}