import java.io.IOException;
import java.util.*;

public class Main{
	public static void main(String[] args){
      Scanner scanner = new Scanner(System.in);
      int sell = scanner.nextInt();
      int buy = scanner.nextInt();
      scanner.nextLine();
      ArrayList<Integer> list = new ArrayList<>();
      while(scanner.hasNextInt()){
      		list.add(scanner.nextInt());
      }
      Collections.sort(list);
      int result = 0;
      for(int i = 0; i < buy; i++){
      	result += list.get(i);
      }
      System.out.println(result);
    }
} import java.io.IOException; IOException java.io import java.util.*; util.* java public class Main{
	public static void main(String[] args){
      Scanner scanner = new Scanner(System.in);
      int sell = scanner.nextInt();
      int buy = scanner.nextInt();
      scanner.nextLine();
      ArrayList<Integer> list = new ArrayList<>();
      while(scanner.hasNextInt()){
      		list.add(scanner.nextInt());
      }
      Collections.sort(list);
      int result = 0;
      for(int i = 0; i < buy; i++){
      	result += list.get(i);
      }
      System.out.println(result);
    }
} Main public static void main(String[] args){
      Scanner scanner = new Scanner(System.in);
      int sell = scanner.nextInt();
      int buy = scanner.nextInt();
      scanner.nextLine();
      ArrayList<Integer> list = new ArrayList<>();
      while(scanner.hasNextInt()){
      		list.add(scanner.nextInt());
      }
      Collections.sort(list);
      int result = 0;
      for(int i = 0; i < buy; i++){
      	result += list.get(i);
      }
      System.out.println(result);
    } main {
      Scanner scanner = new Scanner(System.in);
      int sell = scanner.nextInt();
      int buy = scanner.nextInt();
      scanner.nextLine();
      ArrayList<Integer> list = new ArrayList<>();
      while(scanner.hasNextInt()){
      		list.add(scanner.nextInt());
      }
      Collections.sort(list);
      int result = 0;
      for(int i = 0; i < buy; i++){
      	result += list.get(i);
      }
      System.out.println(result);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int sell = scanner.nextInt(); sell scanner.nextInt() scanner.nextInt scanner int buy = scanner.nextInt(); buy scanner.nextInt() scanner.nextInt scanner scanner.nextLine() scanner.nextLine scanner ArrayList<Integer> list = new ArrayList<>(); list new ArrayList<>() while(scanner.hasNextInt()){
      		list.add(scanner.nextInt());
      } scanner.hasNextInt() scanner.hasNextInt scanner {
      		list.add(scanner.nextInt());
      } list.add(scanner.nextInt()) list.add list scanner.nextInt() scanner.nextInt scanner Collections.sort(list) Collections.sort Collections list int result = 0; result 0 for(int i = 0; i < buy; i++){
      	result += list.get(i);
      } int i = 0; int i = 0; i 0 i < buy i buy i++ i++ i {
      	result += list.get(i);
      } {
      	result += list.get(i);
      } result += list.get(i) result list.get(i) list.get list i System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main{
	public static void main(String[] args){
      Scanner scanner = new Scanner(System.in);
      int sell = scanner.nextInt();
      int buy = scanner.nextInt();
      scanner.nextLine();
      ArrayList<Integer> list = new ArrayList<>();
      while(scanner.hasNextInt()){
      		list.add(scanner.nextInt());
      }
      Collections.sort(list);
      int result = 0;
      for(int i = 0; i < buy; i++){
      	result += list.get(i);
      }
      System.out.println(result);
    }
} public class Main{
	public static void main(String[] args){
      Scanner scanner = new Scanner(System.in);
      int sell = scanner.nextInt();
      int buy = scanner.nextInt();
      scanner.nextLine();
      ArrayList<Integer> list = new ArrayList<>();
      while(scanner.hasNextInt()){
      		list.add(scanner.nextInt());
      }
      Collections.sort(list);
      int result = 0;
      for(int i = 0; i < buy; i++){
      	result += list.get(i);
      }
      System.out.println(result);
    }
} Main
import java.io.IOException;
import java.util.*;

public class Main{
	public static void main(String[] args){
      Scanner scanner = new Scanner(System.in);
      int sell = scanner.nextInt();
      int buy = scanner.nextInt();
      scanner.nextLine();
      ArrayList<Integer> list = new ArrayList<>();
      while(scanner.hasNextInt()){
      		list.add(scanner.nextInt());
      }
      Collections.sort(list);
      int result = 0;
      for(int i = 0; i < buy; i++){
      	result += list.get(i);
      }
      System.out.println(result);
    }
}