import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 998244353;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	long inf = LMAX / 2 - MAX;

	void doIt() {
		int N = sc.nextInt();
		int K = sc.nextInt();
		int p[] = new int[N];
		for(int i = 0; i < N; i++)
			p[i] = sc.nextInt();
		Arrays.sort(p);
		int sum = 0;
		for(int i = 0; i < K; i++) {
			sum += p[i];
		}
		System.out.println(sum);
	}

	public static void main(String[] args) {
		new Main().doIt();
	}
} import java.util.*; util.* java public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 998244353;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	long inf = LMAX / 2 - MAX;

	void doIt() {
		int N = sc.nextInt();
		int K = sc.nextInt();
		int p[] = new int[N];
		for(int i = 0; i < N; i++)
			p[i] = sc.nextInt();
		Arrays.sort(p);
		int sum = 0;
		for(int i = 0; i < K; i++) {
			sum += p[i];
		}
		System.out.println(sum);
	}

	public static void main(String[] args) {
		new Main().doIt();
	}
} Main Scanner sc = new Scanner(System.in); sc new Scanner(System.in) final int MOD = 998244353; MOD 998244353 final int MAX = Integer.MAX_VALUE; MAX Integer.MAX_VALUE Integer Integer.MAX_VALUE final long LMAX = Long.MAX_VALUE; LMAX Long.MAX_VALUE Long Long.MAX_VALUE long inf = LMAX / 2 - MAX; inf LMAX / 2 - MAX LMAX / 2 LMAX 2 MAX void doIt() {
		int N = sc.nextInt();
		int K = sc.nextInt();
		int p[] = new int[N];
		for(int i = 0; i < N; i++)
			p[i] = sc.nextInt();
		Arrays.sort(p);
		int sum = 0;
		for(int i = 0; i < K; i++) {
			sum += p[i];
		}
		System.out.println(sum);
	} doIt {
		int N = sc.nextInt();
		int K = sc.nextInt();
		int p[] = new int[N];
		for(int i = 0; i < N; i++)
			p[i] = sc.nextInt();
		Arrays.sort(p);
		int sum = 0;
		for(int i = 0; i < K; i++) {
			sum += p[i];
		}
		System.out.println(sum);
	} int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int K = sc.nextInt(); K sc.nextInt() sc.nextInt sc int p[] = new int[N]; p new int[N] N for(int i = 0; i < N; i++)
			p[i] = sc.nextInt(); int i = 0; int i = 0; i 0 i < N i N i++ i++ i p[i] = sc.nextInt(); p[i] = sc.nextInt() p[i] p i sc.nextInt() sc.nextInt sc Arrays.sort(p) Arrays.sort Arrays p int sum = 0; sum 0 for(int i = 0; i < K; i++) {
			sum += p[i];
		} int i = 0; int i = 0; i 0 i < K i K i++ i++ i {
			sum += p[i];
		} {
			sum += p[i];
		} sum += p[i] sum p[i] p i System.out.println(sum) System.out.println System.out System System.out sum public static void main(String[] args) {
		new Main().doIt();
	} main {
		new Main().doIt();
	} new Main().doIt() new Main().doIt new Main() String[] args args public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 998244353;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	long inf = LMAX / 2 - MAX;

	void doIt() {
		int N = sc.nextInt();
		int K = sc.nextInt();
		int p[] = new int[N];
		for(int i = 0; i < N; i++)
			p[i] = sc.nextInt();
		Arrays.sort(p);
		int sum = 0;
		for(int i = 0; i < K; i++) {
			sum += p[i];
		}
		System.out.println(sum);
	}

	public static void main(String[] args) {
		new Main().doIt();
	}
} public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 998244353;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	long inf = LMAX / 2 - MAX;

	void doIt() {
		int N = sc.nextInt();
		int K = sc.nextInt();
		int p[] = new int[N];
		for(int i = 0; i < N; i++)
			p[i] = sc.nextInt();
		Arrays.sort(p);
		int sum = 0;
		for(int i = 0; i < K; i++) {
			sum += p[i];
		}
		System.out.println(sum);
	}

	public static void main(String[] args) {
		new Main().doIt();
	}
} Main
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 998244353;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	long inf = LMAX / 2 - MAX;

	void doIt() {
		int N = sc.nextInt();
		int K = sc.nextInt();
		int p[] = new int[N];
		for(int i = 0; i < N; i++)
			p[i] = sc.nextInt();
		Arrays.sort(p);
		int sum = 0;
		for(int i = 0; i < K; i++) {
			sum += p[i];
		}
		System.out.println(sum);
	}

	public static void main(String[] args) {
		new Main().doIt();
	}
}
