import java.util.*;
import java.util.Collections;
public class Main {
	public static void main(String[] args){
 
      Scanner sc = null;
      sc = new Scanner(System.in);
      int N = sc.nextInt();
      int K = sc.nextInt();
      long sumPrice = 0;
      ArrayList<Integer> pList = new ArrayList<Integer>();
      while(sc.hasNextInt()){
        pList.add(sc.nextInt());
      }
      Collections.sort(pList);
      for(int i=0; i < K; i++){
        sumPrice += pList.get(i);
      }
      System.out.println(sumPrice);
    }
} import java.util.*; util.* java import java.util.Collections; Collections java.util public class Main {
	public static void main(String[] args){
 
      Scanner sc = null;
      sc = new Scanner(System.in);
      int N = sc.nextInt();
      int K = sc.nextInt();
      long sumPrice = 0;
      ArrayList<Integer> pList = new ArrayList<Integer>();
      while(sc.hasNextInt()){
        pList.add(sc.nextInt());
      }
      Collections.sort(pList);
      for(int i=0; i < K; i++){
        sumPrice += pList.get(i);
      }
      System.out.println(sumPrice);
    }
} Main public static void main(String[] args){
 
      Scanner sc = null;
      sc = new Scanner(System.in);
      int N = sc.nextInt();
      int K = sc.nextInt();
      long sumPrice = 0;
      ArrayList<Integer> pList = new ArrayList<Integer>();
      while(sc.hasNextInt()){
        pList.add(sc.nextInt());
      }
      Collections.sort(pList);
      for(int i=0; i < K; i++){
        sumPrice += pList.get(i);
      }
      System.out.println(sumPrice);
    } main {
 
      Scanner sc = null;
      sc = new Scanner(System.in);
      int N = sc.nextInt();
      int K = sc.nextInt();
      long sumPrice = 0;
      ArrayList<Integer> pList = new ArrayList<Integer>();
      while(sc.hasNextInt()){
        pList.add(sc.nextInt());
      }
      Collections.sort(pList);
      for(int i=0; i < K; i++){
        sumPrice += pList.get(i);
      }
      System.out.println(sumPrice);
    } Scanner sc = null; sc null sc = new Scanner(System.in) sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int K = sc.nextInt(); K sc.nextInt() sc.nextInt sc long sumPrice = 0; sumPrice 0 ArrayList<Integer> pList = new ArrayList<Integer>(); pList new ArrayList<Integer>() while(sc.hasNextInt()){
        pList.add(sc.nextInt());
      } sc.hasNextInt() sc.hasNextInt sc {
        pList.add(sc.nextInt());
      } pList.add(sc.nextInt()) pList.add pList sc.nextInt() sc.nextInt sc Collections.sort(pList) Collections.sort Collections pList for(int i=0; i < K; i++){
        sumPrice += pList.get(i);
      } int i=0; int i=0; i 0 i < K i K i++ i++ i {
        sumPrice += pList.get(i);
      } {
        sumPrice += pList.get(i);
      } sumPrice += pList.get(i) sumPrice pList.get(i) pList.get pList i System.out.println(sumPrice) System.out.println System.out System System.out sumPrice String[] args args public class Main {
	public static void main(String[] args){
 
      Scanner sc = null;
      sc = new Scanner(System.in);
      int N = sc.nextInt();
      int K = sc.nextInt();
      long sumPrice = 0;
      ArrayList<Integer> pList = new ArrayList<Integer>();
      while(sc.hasNextInt()){
        pList.add(sc.nextInt());
      }
      Collections.sort(pList);
      for(int i=0; i < K; i++){
        sumPrice += pList.get(i);
      }
      System.out.println(sumPrice);
    }
} public class Main {
	public static void main(String[] args){
 
      Scanner sc = null;
      sc = new Scanner(System.in);
      int N = sc.nextInt();
      int K = sc.nextInt();
      long sumPrice = 0;
      ArrayList<Integer> pList = new ArrayList<Integer>();
      while(sc.hasNextInt()){
        pList.add(sc.nextInt());
      }
      Collections.sort(pList);
      for(int i=0; i < K; i++){
        sumPrice += pList.get(i);
      }
      System.out.println(sumPrice);
    }
} Main
import java.util.*;
import java.util.Collections;
public class Main {
	public static void main(String[] args){
 
      Scanner sc = null;
      sc = new Scanner(System.in);
      int N = sc.nextInt();
      int K = sc.nextInt();
      long sumPrice = 0;
      ArrayList<Integer> pList = new ArrayList<Integer>();
      while(sc.hasNextInt()){
        pList.add(sc.nextInt());
      }
      Collections.sort(pList);
      for(int i=0; i < K; i++){
        sumPrice += pList.get(i);
      }
      System.out.println(sumPrice);
    }
}