import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    Integer n = sc.nextInt();
    Integer k = sc.nextInt();
    ArrayList<Integer> ps = new ArrayList<>();
    for (int i = 0; i < n; i++) {
      ps.add(sc.nextInt());
    }
    Collections.sort(ps);
    Integer res = 0;
    for (int i=0;i<k;i++){
      res += ps.get(i);
    }

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

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

    System.out.println(res);
  } main {
    Scanner sc = new Scanner(System.in);
    Integer n = sc.nextInt();
    Integer k = sc.nextInt();
    ArrayList<Integer> ps = new ArrayList<>();
    for (int i = 0; i < n; i++) {
      ps.add(sc.nextInt());
    }
    Collections.sort(ps);
    Integer res = 0;
    for (int i=0;i<k;i++){
      res += ps.get(i);
    }

    System.out.println(res);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) Integer n = sc.nextInt(); n sc.nextInt() sc.nextInt sc Integer k = sc.nextInt(); k sc.nextInt() sc.nextInt sc ArrayList<Integer> ps = new ArrayList<>(); ps new ArrayList<>() for (int i = 0; i < n; i++) {
      ps.add(sc.nextInt());
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      ps.add(sc.nextInt());
    } {
      ps.add(sc.nextInt());
    } ps.add(sc.nextInt()) ps.add ps sc.nextInt() sc.nextInt sc Collections.sort(ps) Collections.sort Collections ps Integer res = 0; res 0 for (int i=0;i<k;i++){
      res += ps.get(i);
    } int i=0; int i=0; i 0 i<k i k i++ i++ i {
      res += ps.get(i);
    } {
      res += ps.get(i);
    } res += ps.get(i) res ps.get(i) ps.get ps i System.out.println(res) System.out.println System.out System System.out res String[] args args
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    Integer n = sc.nextInt();
    Integer k = sc.nextInt();
    ArrayList<Integer> ps = new ArrayList<>();
    for (int i = 0; i < n; i++) {
      ps.add(sc.nextInt());
    }
    Collections.sort(ps);
    Integer res = 0;
    for (int i=0;i<k;i++){
      res += ps.get(i);
    }

    System.out.println(res);
  }
}
