import java.util.*;
 
class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    //種類
    int n = sc.nextInt();
    //買う数
    int k = sc.nextInt();
    
    int[] p = new int[n];
    
    
    
    for(int i = 0; i < n;i++){
    	p[i] = sc.nextInt();
    }
    
    if(n == 1){
      System.out.println(p[0]);
      return;
    }
    
    Arrays.sort(p);
    
    int total = 0;
    for(int i = 0; i < k;i++){
      total += p[i];
    }
    
    System.out.println(total);
    
  }
} import java.util.*; util.* java class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    //種類
    int n = sc.nextInt();
    //買う数
    int k = sc.nextInt();
    
    int[] p = new int[n];
    
    
    
    for(int i = 0; i < n;i++){
    	p[i] = sc.nextInt();
    }
    
    if(n == 1){
      System.out.println(p[0]);
      return;
    }
    
    Arrays.sort(p);
    
    int total = 0;
    for(int i = 0; i < k;i++){
      total += p[i];
    }
    
    System.out.println(total);
    
  }
} Main public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    //種類
    int n = sc.nextInt();
    //買う数
    int k = sc.nextInt();
    
    int[] p = new int[n];
    
    
    
    for(int i = 0; i < n;i++){
    	p[i] = sc.nextInt();
    }
    
    if(n == 1){
      System.out.println(p[0]);
      return;
    }
    
    Arrays.sort(p);
    
    int total = 0;
    for(int i = 0; i < k;i++){
      total += p[i];
    }
    
    System.out.println(total);
    
  } main {
    Scanner sc = new Scanner(System.in);
    //種類
    int n = sc.nextInt();
    //買う数
    int k = sc.nextInt();
    
    int[] p = new int[n];
    
    
    
    for(int i = 0; i < n;i++){
    	p[i] = sc.nextInt();
    }
    
    if(n == 1){
      System.out.println(p[0]);
      return;
    }
    
    Arrays.sort(p);
    
    int total = 0;
    for(int i = 0; i < k;i++){
      total += p[i];
    }
    
    System.out.println(total);
    
  } 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[] p = new int[n]; p new int[n] n for(int i = 0; i < n;i++){
    	p[i] = sc.nextInt();
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
    	p[i] = sc.nextInt();
    } {
    	p[i] = sc.nextInt();
    } p[i] = sc.nextInt() p[i] p i sc.nextInt() sc.nextInt sc if(n == 1){
      System.out.println(p[0]);
      return;
    } n == 1 n 1 {
      System.out.println(p[0]);
      return;
    } System.out.println(p[0]) System.out.println System.out System System.out p[0] p 0 return; Arrays.sort(p) Arrays.sort Arrays p int total = 0; total 0 for(int i = 0; i < k;i++){
      total += p[i];
    } int i = 0; int i = 0; i 0 i < k i k i++ i++ i {
      total += p[i];
    } {
      total += p[i];
    } total += p[i] total p[i] p i System.out.println(total) System.out.println System.out System System.out total String args[] args
import java.util.*;
 
class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    //種類
    int n = sc.nextInt();
    //買う数
    int k = sc.nextInt();
    
    int[] p = new int[n];
    
    
    
    for(int i = 0; i < n;i++){
    	p[i] = sc.nextInt();
    }
    
    if(n == 1){
      System.out.println(p[0]);
      return;
    }
    
    Arrays.sort(p);
    
    int total = 0;
    for(int i = 0; i < k;i++){
      total += p[i];
    }
    
    System.out.println(total);
    
  }
}