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

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int k = sc.nextInt();

			int[] f = new int[n];

			for (int i = 0; i < n; i++) {
				f[i] = sc.nextInt();
			}

			Arrays.sort(f);
			
			int ans = 0;

			for (int i = 0; i < k; i++) {
				ans += f[i];
			}

			System.out.println(ans);

		} catch (Exception e) {
			// TODO: handle exception
		}
	}
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int k = sc.nextInt();

			int[] f = new int[n];

			for (int i = 0; i < n; i++) {
				f[i] = sc.nextInt();
			}

			Arrays.sort(f);
			
			int ans = 0;

			for (int i = 0; i < k; i++) {
				ans += f[i];
			}

			System.out.println(ans);

		} catch (Exception e) {
			// TODO: handle exception
		}
	}
} Main public static void main(String[] args) {
		// TODO Auto-generated method stub
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int k = sc.nextInt();

			int[] f = new int[n];

			for (int i = 0; i < n; i++) {
				f[i] = sc.nextInt();
			}

			Arrays.sort(f);
			
			int ans = 0;

			for (int i = 0; i < k; i++) {
				ans += f[i];
			}

			System.out.println(ans);

		} catch (Exception e) {
			// TODO: handle exception
		}
	} main {
		// TODO Auto-generated method stub
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int k = sc.nextInt();

			int[] f = new int[n];

			for (int i = 0; i < n; i++) {
				f[i] = sc.nextInt();
			}

			Arrays.sort(f);
			
			int ans = 0;

			for (int i = 0; i < k; i++) {
				ans += f[i];
			}

			System.out.println(ans);

		} catch (Exception e) {
			// TODO: handle exception
		}
	} try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int k = sc.nextInt();

			int[] f = new int[n];

			for (int i = 0; i < n; i++) {
				f[i] = sc.nextInt();
			}

			Arrays.sort(f);
			
			int ans = 0;

			for (int i = 0; i < k; i++) {
				ans += f[i];
			}

			System.out.println(ans);

		} catch (Exception e) {
			// TODO: handle exception
		} catch (Exception e) {
			// TODO: handle exception
		} Exception e {
			// TODO: handle exception
		} {
			int n = sc.nextInt();
			int k = sc.nextInt();

			int[] f = new int[n];

			for (int i = 0; i < n; i++) {
				f[i] = sc.nextInt();
			}

			Arrays.sort(f);
			
			int ans = 0;

			for (int i = 0; i < k; i++) {
				ans += f[i];
			}

			System.out.println(ans);

		} Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) 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[] f = new int[n]; f new int[n] n for (int i = 0; i < n; i++) {
				f[i] = sc.nextInt();
			} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
				f[i] = sc.nextInt();
			} {
				f[i] = sc.nextInt();
			} f[i] = sc.nextInt() f[i] f i sc.nextInt() sc.nextInt sc Arrays.sort(f) Arrays.sort Arrays f int ans = 0; ans 0 for (int i = 0; i < k; i++) {
				ans += f[i];
			} int i = 0; int i = 0; i 0 i < k i k i++ i++ i {
				ans += f[i];
			} {
				ans += f[i];
			} ans += f[i] ans f[i] f i System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int k = sc.nextInt();

			int[] f = new int[n];

			for (int i = 0; i < n; i++) {
				f[i] = sc.nextInt();
			}

			Arrays.sort(f);
			
			int ans = 0;

			for (int i = 0; i < k; i++) {
				ans += f[i];
			}

			System.out.println(ans);

		} catch (Exception e) {
			// TODO: handle exception
		}
	}
} public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int k = sc.nextInt();

			int[] f = new int[n];

			for (int i = 0; i < n; i++) {
				f[i] = sc.nextInt();
			}

			Arrays.sort(f);
			
			int ans = 0;

			for (int i = 0; i < k; i++) {
				ans += f[i];
			}

			System.out.println(ans);

		} catch (Exception e) {
			// TODO: handle exception
		}
	}
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int k = sc.nextInt();

			int[] f = new int[n];

			for (int i = 0; i < n; i++) {
				f[i] = sc.nextInt();
			}

			Arrays.sort(f);
			
			int ans = 0;

			for (int i = 0; i < k; i++) {
				ans += f[i];
			}

			System.out.println(ans);

		} catch (Exception e) {
			// TODO: handle exception
		}
	}
}
