import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int res = 0;
    ArrayList<Integer> list = new ArrayList<>();
    for (int i = 0; i < n; i++) {
      list.add(sc.nextInt());
    }
    list.sort(Comparator.naturalOrder());
    for (int i = 0; i < k; i++) {
      res += list.get(i);
    }
    System.out.println(res);
    sc.close();
  }
} import java.util.*; util.* java public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int res = 0;
    ArrayList<Integer> list = new ArrayList<>();
    for (int i = 0; i < n; i++) {
      list.add(sc.nextInt());
    }
    list.sort(Comparator.naturalOrder());
    for (int i = 0; i < k; i++) {
      res += list.get(i);
    }
    System.out.println(res);
    sc.close();
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int res = 0;
    ArrayList<Integer> list = new ArrayList<>();
    for (int i = 0; i < n; i++) {
      list.add(sc.nextInt());
    }
    list.sort(Comparator.naturalOrder());
    for (int i = 0; i < k; i++) {
      res += list.get(i);
    }
    System.out.println(res);
    sc.close();
  } main {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int res = 0;
    ArrayList<Integer> list = new ArrayList<>();
    for (int i = 0; i < n; i++) {
      list.add(sc.nextInt());
    }
    list.sort(Comparator.naturalOrder());
    for (int i = 0; i < k; i++) {
      res += list.get(i);
    }
    System.out.println(res);
    sc.close();
  } 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 res = 0; res 0 ArrayList<Integer> list = new ArrayList<>(); list new ArrayList<>() for (int i = 0; i < n; i++) {
      list.add(sc.nextInt());
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      list.add(sc.nextInt());
    } {
      list.add(sc.nextInt());
    } list.add(sc.nextInt()) list.add list sc.nextInt() sc.nextInt sc list.sort(Comparator.naturalOrder()) list.sort list Comparator.naturalOrder() Comparator.naturalOrder Comparator for (int i = 0; i < k; i++) {
      res += list.get(i);
    } int i = 0; int i = 0; i 0 i < k i k i++ i++ i {
      res += list.get(i);
    } {
      res += list.get(i);
    } res += list.get(i) res list.get(i) list.get list i System.out.println(res) System.out.println System.out System System.out res sc.close() sc.close sc String[] args args public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int res = 0;
    ArrayList<Integer> list = new ArrayList<>();
    for (int i = 0; i < n; i++) {
      list.add(sc.nextInt());
    }
    list.sort(Comparator.naturalOrder());
    for (int i = 0; i < k; i++) {
      res += list.get(i);
    }
    System.out.println(res);
    sc.close();
  }
} public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int res = 0;
    ArrayList<Integer> list = new ArrayList<>();
    for (int i = 0; i < n; i++) {
      list.add(sc.nextInt());
    }
    list.sort(Comparator.naturalOrder());
    for (int i = 0; i < k; i++) {
      res += list.get(i);
    }
    System.out.println(res);
    sc.close();
  }
} Main
import java.util.*;

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