import java.util.*;

public class Main {
  public static void main(String args[]) {
    Scanner scanner = new Scanner(System.in);
    int n,k;
    n = scanner.nextInt();
    k = scanner.nextInt();
    
    ArrayList<Integer> p = new ArrayList<Integer>();
    
    int x;
    for(int i = 0;i < n ; i++) { 
      x = scanner.nextInt();
      p.add(x);
    }
    
    Collections.sort(p);
    
    int ans = 0;
    for(int i = 0; i < k;i++) { 
      ans+=p.get(i);
    }
    
    System.out.println(ans);
}
} import java.util.*; util.* java public class Main {
  public static void main(String args[]) {
    Scanner scanner = new Scanner(System.in);
    int n,k;
    n = scanner.nextInt();
    k = scanner.nextInt();
    
    ArrayList<Integer> p = new ArrayList<Integer>();
    
    int x;
    for(int i = 0;i < n ; i++) { 
      x = scanner.nextInt();
      p.add(x);
    }
    
    Collections.sort(p);
    
    int ans = 0;
    for(int i = 0; i < k;i++) { 
      ans+=p.get(i);
    }
    
    System.out.println(ans);
}
} Main public static void main(String args[]) {
    Scanner scanner = new Scanner(System.in);
    int n,k;
    n = scanner.nextInt();
    k = scanner.nextInt();
    
    ArrayList<Integer> p = new ArrayList<Integer>();
    
    int x;
    for(int i = 0;i < n ; i++) { 
      x = scanner.nextInt();
      p.add(x);
    }
    
    Collections.sort(p);
    
    int ans = 0;
    for(int i = 0; i < k;i++) { 
      ans+=p.get(i);
    }
    
    System.out.println(ans);
} main {
    Scanner scanner = new Scanner(System.in);
    int n,k;
    n = scanner.nextInt();
    k = scanner.nextInt();
    
    ArrayList<Integer> p = new ArrayList<Integer>();
    
    int x;
    for(int i = 0;i < n ; i++) { 
      x = scanner.nextInt();
      p.add(x);
    }
    
    Collections.sort(p);
    
    int ans = 0;
    for(int i = 0; i < k;i++) { 
      ans+=p.get(i);
    }
    
    System.out.println(ans);
} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int n n k; k n = scanner.nextInt() n scanner.nextInt() scanner.nextInt scanner k = scanner.nextInt() k scanner.nextInt() scanner.nextInt scanner ArrayList<Integer> p = new ArrayList<Integer>(); p new ArrayList<Integer>() int x; x for(int i = 0;i < n ; i++) { 
      x = scanner.nextInt();
      p.add(x);
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i { 
      x = scanner.nextInt();
      p.add(x);
    } { 
      x = scanner.nextInt();
      p.add(x);
    } x = scanner.nextInt() x scanner.nextInt() scanner.nextInt scanner p.add(x) p.add p x Collections.sort(p) Collections.sort Collections p int ans = 0; ans 0 for(int i = 0; i < k;i++) { 
      ans+=p.get(i);
    } int i = 0; int i = 0; i 0 i < k i k i++ i++ i { 
      ans+=p.get(i);
    } { 
      ans+=p.get(i);
    } ans+=p.get(i) ans p.get(i) p.get p i System.out.println(ans) System.out.println System.out System System.out ans String args[] args public class Main {
  public static void main(String args[]) {
    Scanner scanner = new Scanner(System.in);
    int n,k;
    n = scanner.nextInt();
    k = scanner.nextInt();
    
    ArrayList<Integer> p = new ArrayList<Integer>();
    
    int x;
    for(int i = 0;i < n ; i++) { 
      x = scanner.nextInt();
      p.add(x);
    }
    
    Collections.sort(p);
    
    int ans = 0;
    for(int i = 0; i < k;i++) { 
      ans+=p.get(i);
    }
    
    System.out.println(ans);
}
} public class Main {
  public static void main(String args[]) {
    Scanner scanner = new Scanner(System.in);
    int n,k;
    n = scanner.nextInt();
    k = scanner.nextInt();
    
    ArrayList<Integer> p = new ArrayList<Integer>();
    
    int x;
    for(int i = 0;i < n ; i++) { 
      x = scanner.nextInt();
      p.add(x);
    }
    
    Collections.sort(p);
    
    int ans = 0;
    for(int i = 0; i < k;i++) { 
      ans+=p.get(i);
    }
    
    System.out.println(ans);
}
} Main
import java.util.*;

public class Main {
  public static void main(String args[]) {
    Scanner scanner = new Scanner(System.in);
    int n,k;
    n = scanner.nextInt();
    k = scanner.nextInt();
    
    ArrayList<Integer> p = new ArrayList<Integer>();
    
    int x;
    for(int i = 0;i < n ; i++) { 
      x = scanner.nextInt();
      p.add(x);
    }
    
    Collections.sort(p);
    
    int ans = 0;
    for(int i = 0; i < k;i++) { 
      ans+=p.get(i);
    }
    
    System.out.println(ans);
}
}