import java.util.*;

public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    
    int[] price = new int[N];
    for(int i=0;i<N;i++){
      price[i] = sc.nextInt();
    }
    
    Arrays.sort(price);
    
    int money = 0;
    for(int i=0;i<K;i++){
      money = money + price[i];
    }
    
    System.out.println(String.valueOf(money));
  }
} import java.util.*; util.* java public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    
    int[] price = new int[N];
    for(int i=0;i<N;i++){
      price[i] = sc.nextInt();
    }
    
    Arrays.sort(price);
    
    int money = 0;
    for(int i=0;i<K;i++){
      money = money + price[i];
    }
    
    System.out.println(String.valueOf(money));
  }
} Main public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    
    int[] price = new int[N];
    for(int i=0;i<N;i++){
      price[i] = sc.nextInt();
    }
    
    Arrays.sort(price);
    
    int money = 0;
    for(int i=0;i<K;i++){
      money = money + price[i];
    }
    
    System.out.println(String.valueOf(money));
  } main {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    
    int[] price = new int[N];
    for(int i=0;i<N;i++){
      price[i] = sc.nextInt();
    }
    
    Arrays.sort(price);
    
    int money = 0;
    for(int i=0;i<K;i++){
      money = money + price[i];
    }
    
    System.out.println(String.valueOf(money));
  } Scanner 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 int[] price = new int[N]; price new int[N] N for(int i=0;i<N;i++){
      price[i] = sc.nextInt();
    } int i=0; int i=0; i 0 i<N i N i++ i++ i {
      price[i] = sc.nextInt();
    } {
      price[i] = sc.nextInt();
    } price[i] = sc.nextInt() price[i] price i sc.nextInt() sc.nextInt sc Arrays.sort(price) Arrays.sort Arrays price int money = 0; money 0 for(int i=0;i<K;i++){
      money = money + price[i];
    } int i=0; int i=0; i 0 i<K i K i++ i++ i {
      money = money + price[i];
    } {
      money = money + price[i];
    } money = money + price[i] money money + price[i] money price[i] price i System.out.println(String.valueOf(money)) System.out.println System.out System System.out String.valueOf(money) String.valueOf String money String[] args args public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    
    int[] price = new int[N];
    for(int i=0;i<N;i++){
      price[i] = sc.nextInt();
    }
    
    Arrays.sort(price);
    
    int money = 0;
    for(int i=0;i<K;i++){
      money = money + price[i];
    }
    
    System.out.println(String.valueOf(money));
  }
} public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    
    int[] price = new int[N];
    for(int i=0;i<N;i++){
      price[i] = sc.nextInt();
    }
    
    Arrays.sort(price);
    
    int money = 0;
    for(int i=0;i<K;i++){
      money = money + price[i];
    }
    
    System.out.println(String.valueOf(money));
  }
} Main
import java.util.*;

public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    
    int[] price = new int[N];
    for(int i=0;i<N;i++){
      price[i] = sc.nextInt();
    }
    
    Arrays.sort(price);
    
    int money = 0;
    for(int i=0;i<K;i++){
      money = money + price[i];
    }
    
    System.out.println(String.valueOf(money));
  }
}