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

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String[] str1 = sc.nextLine().split(" ");
    int n = Integer.parseInt(str1[0]);
    int k = Integer.parseInt(str1[1]);

    String[] str2 = sc.nextLine().split(" ");

    int[] int1 = new int[n];
    for(int i = 0; i < n;i++) {
      int1[i] = Integer.parseInt(str2[i]);
    }

    Arrays.sort(int1);
    int count = 0;

    for(int i = 0; i <= k-1;i++) {
      count += int1[i];
    }

    System.out.println(count);

  }

} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String[] str1 = sc.nextLine().split(" ");
    int n = Integer.parseInt(str1[0]);
    int k = Integer.parseInt(str1[1]);

    String[] str2 = sc.nextLine().split(" ");

    int[] int1 = new int[n];
    for(int i = 0; i < n;i++) {
      int1[i] = Integer.parseInt(str2[i]);
    }

    Arrays.sort(int1);
    int count = 0;

    for(int i = 0; i <= k-1;i++) {
      count += int1[i];
    }

    System.out.println(count);

  }

} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String[] str1 = sc.nextLine().split(" ");
    int n = Integer.parseInt(str1[0]);
    int k = Integer.parseInt(str1[1]);

    String[] str2 = sc.nextLine().split(" ");

    int[] int1 = new int[n];
    for(int i = 0; i < n;i++) {
      int1[i] = Integer.parseInt(str2[i]);
    }

    Arrays.sort(int1);
    int count = 0;

    for(int i = 0; i <= k-1;i++) {
      count += int1[i];
    }

    System.out.println(count);

  } main {
    Scanner sc = new Scanner(System.in);
    String[] str1 = sc.nextLine().split(" ");
    int n = Integer.parseInt(str1[0]);
    int k = Integer.parseInt(str1[1]);

    String[] str2 = sc.nextLine().split(" ");

    int[] int1 = new int[n];
    for(int i = 0; i < n;i++) {
      int1[i] = Integer.parseInt(str2[i]);
    }

    Arrays.sort(int1);
    int count = 0;

    for(int i = 0; i <= k-1;i++) {
      count += int1[i];
    }

    System.out.println(count);

  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String[] str1 = sc.nextLine().split(" "); str1 sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine sc " " int n = Integer.parseInt(str1[0]); n Integer.parseInt(str1[0]) Integer.parseInt Integer str1[0] str1 0 int k = Integer.parseInt(str1[1]); k Integer.parseInt(str1[1]) Integer.parseInt Integer str1[1] str1 1 String[] str2 = sc.nextLine().split(" "); str2 sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine sc " " int[] int1 = new int[n]; int1 new int[n] n for(int i = 0; i < n;i++) {
      int1[i] = Integer.parseInt(str2[i]);
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      int1[i] = Integer.parseInt(str2[i]);
    } {
      int1[i] = Integer.parseInt(str2[i]);
    } int1[i] = Integer.parseInt(str2[i]) int1[i] int1 i Integer.parseInt(str2[i]) Integer.parseInt Integer str2[i] str2 i Arrays.sort(int1) Arrays.sort Arrays int1 int count = 0; count 0 for(int i = 0; i <= k-1;i++) {
      count += int1[i];
    } int i = 0; int i = 0; i 0 i <= k-1 i k-1 k 1 i++ i++ i {
      count += int1[i];
    } {
      count += int1[i];
    } count += int1[i] count int1[i] int1 i System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String[] str1 = sc.nextLine().split(" ");
    int n = Integer.parseInt(str1[0]);
    int k = Integer.parseInt(str1[1]);

    String[] str2 = sc.nextLine().split(" ");

    int[] int1 = new int[n];
    for(int i = 0; i < n;i++) {
      int1[i] = Integer.parseInt(str2[i]);
    }

    Arrays.sort(int1);
    int count = 0;

    for(int i = 0; i <= k-1;i++) {
      count += int1[i];
    }

    System.out.println(count);

  }

} public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String[] str1 = sc.nextLine().split(" ");
    int n = Integer.parseInt(str1[0]);
    int k = Integer.parseInt(str1[1]);

    String[] str2 = sc.nextLine().split(" ");

    int[] int1 = new int[n];
    for(int i = 0; i < n;i++) {
      int1[i] = Integer.parseInt(str2[i]);
    }

    Arrays.sort(int1);
    int count = 0;

    for(int i = 0; i <= k-1;i++) {
      count += int1[i];
    }

    System.out.println(count);

  }

} Main

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

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String[] str1 = sc.nextLine().split(" ");
    int n = Integer.parseInt(str1[0]);
    int k = Integer.parseInt(str1[1]);

    String[] str2 = sc.nextLine().split(" ");

    int[] int1 = new int[n];
    for(int i = 0; i < n;i++) {
      int1[i] = Integer.parseInt(str2[i]);
    }

    Arrays.sort(int1);
    int count = 0;

    for(int i = 0; i <= k-1;i++) {
      count += int1[i];
    }

    System.out.println(count);

  }

}
