//package beg_171;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s = new Scanner(System.in);
		String[] a = s.nextLine().split(" ");
		int many = Integer.parseInt(a[1]);
		
		String[] l = s.nextLine().split(" ");
		int[] list = new int[l.length];
		for (int i=0;i<l.length;i++) {
			list[i]=Integer.parseInt(l[i]);		}
		
		Arrays.sort(list);
		int count=0;
		for (int i=0;i<many;i++) {
			count=count+list[i];
		}
		System.out.println(count);
	}

} import java.util.*; util.* java public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s = new Scanner(System.in);
		String[] a = s.nextLine().split(" ");
		int many = Integer.parseInt(a[1]);
		
		String[] l = s.nextLine().split(" ");
		int[] list = new int[l.length];
		for (int i=0;i<l.length;i++) {
			list[i]=Integer.parseInt(l[i]);		}
		
		Arrays.sort(list);
		int count=0;
		for (int i=0;i<many;i++) {
			count=count+list[i];
		}
		System.out.println(count);
	}

} Main public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s = new Scanner(System.in);
		String[] a = s.nextLine().split(" ");
		int many = Integer.parseInt(a[1]);
		
		String[] l = s.nextLine().split(" ");
		int[] list = new int[l.length];
		for (int i=0;i<l.length;i++) {
			list[i]=Integer.parseInt(l[i]);		}
		
		Arrays.sort(list);
		int count=0;
		for (int i=0;i<many;i++) {
			count=count+list[i];
		}
		System.out.println(count);
	} main {
		// TODO Auto-generated method stub
		Scanner s = new Scanner(System.in);
		String[] a = s.nextLine().split(" ");
		int many = Integer.parseInt(a[1]);
		
		String[] l = s.nextLine().split(" ");
		int[] list = new int[l.length];
		for (int i=0;i<l.length;i++) {
			list[i]=Integer.parseInt(l[i]);		}
		
		Arrays.sort(list);
		int count=0;
		for (int i=0;i<many;i++) {
			count=count+list[i];
		}
		System.out.println(count);
	} Scanner s = new Scanner(System.in); s new Scanner(System.in) String[] a = s.nextLine().split(" "); a s.nextLine().split(" ") s.nextLine().split s.nextLine() s.nextLine s " " int many = Integer.parseInt(a[1]); many Integer.parseInt(a[1]) Integer.parseInt Integer a[1] a 1 String[] l = s.nextLine().split(" "); l s.nextLine().split(" ") s.nextLine().split s.nextLine() s.nextLine s " " int[] list = new int[l.length]; list new int[l.length] l.length l l.length for (int i=0;i<l.length;i++) {
			list[i]=Integer.parseInt(l[i]);		} int i=0; int i=0; i 0 i<l.length i l.length l l.length i++ i++ i {
			list[i]=Integer.parseInt(l[i]);		} {
			list[i]=Integer.parseInt(l[i]);		} list[i]=Integer.parseInt(l[i]) list[i] list i Integer.parseInt(l[i]) Integer.parseInt Integer l[i] l i Arrays.sort(list) Arrays.sort Arrays list int count=0; count 0 for (int i=0;i<many;i++) {
			count=count+list[i];
		} int i=0; int i=0; i 0 i<many i many i++ i++ i {
			count=count+list[i];
		} {
			count=count+list[i];
		} count=count+list[i] count count+list[i] count list[i] list i System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s = new Scanner(System.in);
		String[] a = s.nextLine().split(" ");
		int many = Integer.parseInt(a[1]);
		
		String[] l = s.nextLine().split(" ");
		int[] list = new int[l.length];
		for (int i=0;i<l.length;i++) {
			list[i]=Integer.parseInt(l[i]);		}
		
		Arrays.sort(list);
		int count=0;
		for (int i=0;i<many;i++) {
			count=count+list[i];
		}
		System.out.println(count);
	}

} public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s = new Scanner(System.in);
		String[] a = s.nextLine().split(" ");
		int many = Integer.parseInt(a[1]);
		
		String[] l = s.nextLine().split(" ");
		int[] list = new int[l.length];
		for (int i=0;i<l.length;i++) {
			list[i]=Integer.parseInt(l[i]);		}
		
		Arrays.sort(list);
		int count=0;
		for (int i=0;i<many;i++) {
			count=count+list[i];
		}
		System.out.println(count);
	}

} Main
//package beg_171;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s = new Scanner(System.in);
		String[] a = s.nextLine().split(" ");
		int many = Integer.parseInt(a[1]);
		
		String[] l = s.nextLine().split(" ");
		int[] list = new int[l.length];
		for (int i=0;i<l.length;i++) {
			list[i]=Integer.parseInt(l[i]);		}
		
		Arrays.sort(list);
		int count=0;
		for (int i=0;i<many;i++) {
			count=count+list[i];
		}
		System.out.println(count);
	}

}
