import java.util.*;

public class Main {
  public static void main(String[] args) {
    Main main = new Main();
    main.solve();
    main.show();
  }

  int n;
  int k;
  int[] p;
  int ans;

  public Main() {
    Scanner sc = new Scanner(System.in);
    try {
      n = sc.nextInt();
      k = sc.nextInt();
      p = new int[n];
      for (int i = 0; i < n; i++) p[i] = sc.nextInt();
    } finally {
      sc.close();
    }
  }
  
  void solve() {
    Arrays.sort(p);
    for (int i = 0; i < k; i++) ans += p[i];
  }

  void show() {
    System.out.println(ans);
  }
} import java.util.*; util.* java public class Main {
  public static void main(String[] args) {
    Main main = new Main();
    main.solve();
    main.show();
  }

  int n;
  int k;
  int[] p;
  int ans;

  public Main() {
    Scanner sc = new Scanner(System.in);
    try {
      n = sc.nextInt();
      k = sc.nextInt();
      p = new int[n];
      for (int i = 0; i < n; i++) p[i] = sc.nextInt();
    } finally {
      sc.close();
    }
  }
  
  void solve() {
    Arrays.sort(p);
    for (int i = 0; i < k; i++) ans += p[i];
  }

  void show() {
    System.out.println(ans);
  }
} Main int n; n int k; k int[] p; p int ans; ans public static void main(String[] args) {
    Main main = new Main();
    main.solve();
    main.show();
  } main {
    Main main = new Main();
    main.solve();
    main.show();
  } Main main = new Main(); main new Main() main.solve() main.solve main main.show() main.show main String[] args args public Main() {
    Scanner sc = new Scanner(System.in);
    try {
      n = sc.nextInt();
      k = sc.nextInt();
      p = new int[n];
      for (int i = 0; i < n; i++) p[i] = sc.nextInt();
    } finally {
      sc.close();
    }
  } Main {
    Scanner sc = new Scanner(System.in);
    try {
      n = sc.nextInt();
      k = sc.nextInt();
      p = new int[n];
      for (int i = 0; i < n; i++) p[i] = sc.nextInt();
    } finally {
      sc.close();
    }
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) try {
      n = sc.nextInt();
      k = sc.nextInt();
      p = new int[n];
      for (int i = 0; i < n; i++) p[i] = sc.nextInt();
    } finally {
      sc.close();
    } {
      sc.close();
    } sc.close() sc.close sc {
      n = sc.nextInt();
      k = sc.nextInt();
      p = new int[n];
      for (int i = 0; i < n; i++) p[i] = sc.nextInt();
    } n = sc.nextInt() n sc.nextInt() sc.nextInt sc k = sc.nextInt() k sc.nextInt() sc.nextInt sc 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] p i sc.nextInt() sc.nextInt sc void solve() {
    Arrays.sort(p);
    for (int i = 0; i < k; i++) ans += p[i];
  } solve {
    Arrays.sort(p);
    for (int i = 0; i < k; i++) ans += p[i];
  } Arrays.sort(p) Arrays.sort Arrays p for (int i = 0; i < k; i++) ans += p[i]; int i = 0; int i = 0; i 0 i < k i k i++ i++ i ans += p[i]; ans += p[i] ans p[i] p i void show() {
    System.out.println(ans);
  } show {
    System.out.println(ans);
  } System.out.println(ans) System.out.println System.out System System.out ans public class Main {
  public static void main(String[] args) {
    Main main = new Main();
    main.solve();
    main.show();
  }

  int n;
  int k;
  int[] p;
  int ans;

  public Main() {
    Scanner sc = new Scanner(System.in);
    try {
      n = sc.nextInt();
      k = sc.nextInt();
      p = new int[n];
      for (int i = 0; i < n; i++) p[i] = sc.nextInt();
    } finally {
      sc.close();
    }
  }
  
  void solve() {
    Arrays.sort(p);
    for (int i = 0; i < k; i++) ans += p[i];
  }

  void show() {
    System.out.println(ans);
  }
} public class Main {
  public static void main(String[] args) {
    Main main = new Main();
    main.solve();
    main.show();
  }

  int n;
  int k;
  int[] p;
  int ans;

  public Main() {
    Scanner sc = new Scanner(System.in);
    try {
      n = sc.nextInt();
      k = sc.nextInt();
      p = new int[n];
      for (int i = 0; i < n; i++) p[i] = sc.nextInt();
    } finally {
      sc.close();
    }
  }
  
  void solve() {
    Arrays.sort(p);
    for (int i = 0; i < k; i++) ans += p[i];
  }

  void show() {
    System.out.println(ans);
  }
} Main
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Main main = new Main();
    main.solve();
    main.show();
  }

  int n;
  int k;
  int[] p;
  int ans;

  public Main() {
    Scanner sc = new Scanner(System.in);
    try {
      n = sc.nextInt();
      k = sc.nextInt();
      p = new int[n];
      for (int i = 0; i < n; i++) p[i] = sc.nextInt();
    } finally {
      sc.close();
    }
  }
  
  void solve() {
    Arrays.sort(p);
    for (int i = 0; i < k; i++) ans += p[i];
  }

  void show() {
    System.out.println(ans);
  }
}
