import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    b();
  }
  public static void b() {
    try (Scanner sc = new Scanner(System.in)) {
      int n = Integer.parseInt(sc.next());
      int k = Integer.parseInt(sc.next());
      int[] p = new int[n];
      for (int xx = 0; xx < n; xx++) {
        p[xx] = Integer.parseInt(sc.next());
      }
      Arrays.parallelSort(p);

      int goukei = 0;
      for (int ans = 0; ans < k; ans++) {
        goukei += p[ans];
      }

      System.out.println(goukei);

    } catch (Exception E) {
      System.out.println("エラー");
    }
  }
} import java.util.Arrays; Arrays java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util public class Main {
  public static void main(String[] args) {
    b();
  }
  public static void b() {
    try (Scanner sc = new Scanner(System.in)) {
      int n = Integer.parseInt(sc.next());
      int k = Integer.parseInt(sc.next());
      int[] p = new int[n];
      for (int xx = 0; xx < n; xx++) {
        p[xx] = Integer.parseInt(sc.next());
      }
      Arrays.parallelSort(p);

      int goukei = 0;
      for (int ans = 0; ans < k; ans++) {
        goukei += p[ans];
      }

      System.out.println(goukei);

    } catch (Exception E) {
      System.out.println("エラー");
    }
  }
} Main public static void main(String[] args) {
    b();
  } main {
    b();
  } b() b String[] args args public static void b() {
    try (Scanner sc = new Scanner(System.in)) {
      int n = Integer.parseInt(sc.next());
      int k = Integer.parseInt(sc.next());
      int[] p = new int[n];
      for (int xx = 0; xx < n; xx++) {
        p[xx] = Integer.parseInt(sc.next());
      }
      Arrays.parallelSort(p);

      int goukei = 0;
      for (int ans = 0; ans < k; ans++) {
        goukei += p[ans];
      }

      System.out.println(goukei);

    } catch (Exception E) {
      System.out.println("エラー");
    }
  } b {
    try (Scanner sc = new Scanner(System.in)) {
      int n = Integer.parseInt(sc.next());
      int k = Integer.parseInt(sc.next());
      int[] p = new int[n];
      for (int xx = 0; xx < n; xx++) {
        p[xx] = Integer.parseInt(sc.next());
      }
      Arrays.parallelSort(p);

      int goukei = 0;
      for (int ans = 0; ans < k; ans++) {
        goukei += p[ans];
      }

      System.out.println(goukei);

    } catch (Exception E) {
      System.out.println("エラー");
    }
  } try (Scanner sc = new Scanner(System.in)) {
      int n = Integer.parseInt(sc.next());
      int k = Integer.parseInt(sc.next());
      int[] p = new int[n];
      for (int xx = 0; xx < n; xx++) {
        p[xx] = Integer.parseInt(sc.next());
      }
      Arrays.parallelSort(p);

      int goukei = 0;
      for (int ans = 0; ans < k; ans++) {
        goukei += p[ans];
      }

      System.out.println(goukei);

    } catch (Exception E) {
      System.out.println("エラー");
    } catch (Exception E) {
      System.out.println("エラー");
    } Exception E {
      System.out.println("エラー");
    } System.out.println("エラー") System.out.println System.out System System.out "エラー" {
      int n = Integer.parseInt(sc.next());
      int k = Integer.parseInt(sc.next());
      int[] p = new int[n];
      for (int xx = 0; xx < n; xx++) {
        p[xx] = Integer.parseInt(sc.next());
      }
      Arrays.parallelSort(p);

      int goukei = 0;
      for (int ans = 0; ans < k; ans++) {
        goukei += p[ans];
      }

      System.out.println(goukei);

    } Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) new Scanner(System.in) int n = Integer.parseInt(sc.next()); n Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int k = Integer.parseInt(sc.next()); k Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int[] p = new int[n]; p new int[n] n for (int xx = 0; xx < n; xx++) {
        p[xx] = Integer.parseInt(sc.next());
      } int xx = 0; int xx = 0; xx 0 xx < n xx n xx++ xx++ xx {
        p[xx] = Integer.parseInt(sc.next());
      } {
        p[xx] = Integer.parseInt(sc.next());
      } p[xx] = Integer.parseInt(sc.next()) p[xx] p xx Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc Arrays.parallelSort(p) Arrays.parallelSort Arrays p int goukei = 0; goukei 0 for (int ans = 0; ans < k; ans++) {
        goukei += p[ans];
      } int ans = 0; int ans = 0; ans 0 ans < k ans k ans++ ans++ ans {
        goukei += p[ans];
      } {
        goukei += p[ans];
      } goukei += p[ans] goukei p[ans] p ans System.out.println(goukei) System.out.println System.out System System.out goukei public class Main {
  public static void main(String[] args) {
    b();
  }
  public static void b() {
    try (Scanner sc = new Scanner(System.in)) {
      int n = Integer.parseInt(sc.next());
      int k = Integer.parseInt(sc.next());
      int[] p = new int[n];
      for (int xx = 0; xx < n; xx++) {
        p[xx] = Integer.parseInt(sc.next());
      }
      Arrays.parallelSort(p);

      int goukei = 0;
      for (int ans = 0; ans < k; ans++) {
        goukei += p[ans];
      }

      System.out.println(goukei);

    } catch (Exception E) {
      System.out.println("エラー");
    }
  }
} public class Main {
  public static void main(String[] args) {
    b();
  }
  public static void b() {
    try (Scanner sc = new Scanner(System.in)) {
      int n = Integer.parseInt(sc.next());
      int k = Integer.parseInt(sc.next());
      int[] p = new int[n];
      for (int xx = 0; xx < n; xx++) {
        p[xx] = Integer.parseInt(sc.next());
      }
      Arrays.parallelSort(p);

      int goukei = 0;
      for (int ans = 0; ans < k; ans++) {
        goukei += p[ans];
      }

      System.out.println(goukei);

    } catch (Exception E) {
      System.out.println("エラー");
    }
  }
} Main
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    b();
  }
  public static void b() {
    try (Scanner sc = new Scanner(System.in)) {
      int n = Integer.parseInt(sc.next());
      int k = Integer.parseInt(sc.next());
      int[] p = new int[n];
      for (int xx = 0; xx < n; xx++) {
        p[xx] = Integer.parseInt(sc.next());
      }
      Arrays.parallelSort(p);

      int goukei = 0;
      for (int ans = 0; ans < k; ans++) {
        goukei += p[ans];
      }

      System.out.println(goukei);

    } catch (Exception E) {
      System.out.println("エラー");
    }
  }
}