import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
      	int k = Integer.parseInt(sc.next());
      	ArrayList<Integer> list = new ArrayList<>();
      	for(int cnt = 0;cnt < n;cnt++){
        	list.add(Integer.parseInt(sc.next()));
        }
      	Collections.sort(list);
      	int total = 0;
      	for(int cnt = 0;cnt < k;cnt++){
        	total += list.get(cnt);
        }
      	System.out.println(total);
	}
} import java.util.*; util.* java public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
      	int k = Integer.parseInt(sc.next());
      	ArrayList<Integer> list = new ArrayList<>();
      	for(int cnt = 0;cnt < n;cnt++){
        	list.add(Integer.parseInt(sc.next()));
        }
      	Collections.sort(list);
      	int total = 0;
      	for(int cnt = 0;cnt < k;cnt++){
        	total += list.get(cnt);
        }
      	System.out.println(total);
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
      	int k = Integer.parseInt(sc.next());
      	ArrayList<Integer> list = new ArrayList<>();
      	for(int cnt = 0;cnt < n;cnt++){
        	list.add(Integer.parseInt(sc.next()));
        }
      	Collections.sort(list);
      	int total = 0;
      	for(int cnt = 0;cnt < k;cnt++){
        	total += list.get(cnt);
        }
      	System.out.println(total);
	} main {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
      	int k = Integer.parseInt(sc.next());
      	ArrayList<Integer> list = new ArrayList<>();
      	for(int cnt = 0;cnt < n;cnt++){
        	list.add(Integer.parseInt(sc.next()));
        }
      	Collections.sort(list);
      	int total = 0;
      	for(int cnt = 0;cnt < k;cnt++){
        	total += list.get(cnt);
        }
      	System.out.println(total);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = Integer.parseInt(sc.next()); n Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int k = Integer.parseInt(sc.next()); k Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc ArrayList<Integer> list = new ArrayList<>(); list new ArrayList<>() for(int cnt = 0;cnt < n;cnt++){
        	list.add(Integer.parseInt(sc.next()));
        } int cnt = 0; int cnt = 0; cnt 0 cnt < n cnt n cnt++ cnt++ cnt {
        	list.add(Integer.parseInt(sc.next()));
        } {
        	list.add(Integer.parseInt(sc.next()));
        } list.add(Integer.parseInt(sc.next())) list.add list Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc Collections.sort(list) Collections.sort Collections list int total = 0; total 0 for(int cnt = 0;cnt < k;cnt++){
        	total += list.get(cnt);
        } int cnt = 0; int cnt = 0; cnt 0 cnt < k cnt k cnt++ cnt++ cnt {
        	total += list.get(cnt);
        } {
        	total += list.get(cnt);
        } total += list.get(cnt) total list.get(cnt) list.get list cnt System.out.println(total) System.out.println System.out System System.out total String[] args args public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
      	int k = Integer.parseInt(sc.next());
      	ArrayList<Integer> list = new ArrayList<>();
      	for(int cnt = 0;cnt < n;cnt++){
        	list.add(Integer.parseInt(sc.next()));
        }
      	Collections.sort(list);
      	int total = 0;
      	for(int cnt = 0;cnt < k;cnt++){
        	total += list.get(cnt);
        }
      	System.out.println(total);
	}
} public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
      	int k = Integer.parseInt(sc.next());
      	ArrayList<Integer> list = new ArrayList<>();
      	for(int cnt = 0;cnt < n;cnt++){
        	list.add(Integer.parseInt(sc.next()));
        }
      	Collections.sort(list);
      	int total = 0;
      	for(int cnt = 0;cnt < k;cnt++){
        	total += list.get(cnt);
        }
      	System.out.println(total);
	}
} Main
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
      	int k = Integer.parseInt(sc.next());
      	ArrayList<Integer> list = new ArrayList<>();
      	for(int cnt = 0;cnt < n;cnt++){
        	list.add(Integer.parseInt(sc.next()));
        }
      	Collections.sort(list);
      	int total = 0;
      	for(int cnt = 0;cnt < k;cnt++){
        	total += list.get(cnt);
        }
      	System.out.println(total);
	}
}