import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int[] nk = new int[2];
    for (int i = 0; i < nk.length; i++){
      nk[i] = sc.nextInt();
    }
    sc.nextLine();
    int[] pn = new int[nk[0]];
	for (int i = 0; i < nk[0]; i++){
      pn[i] = sc.nextInt();
    }
    Arrays.sort(pn);
    int answer = 0;
    for (int i = 0; i < nk[1]; i++){
      answer += pn[i];
    }
    System.out.println(answer);
  }
} import java.util.*; util.* java public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int[] nk = new int[2];
    for (int i = 0; i < nk.length; i++){
      nk[i] = sc.nextInt();
    }
    sc.nextLine();
    int[] pn = new int[nk[0]];
	for (int i = 0; i < nk[0]; i++){
      pn[i] = sc.nextInt();
    }
    Arrays.sort(pn);
    int answer = 0;
    for (int i = 0; i < nk[1]; i++){
      answer += pn[i];
    }
    System.out.println(answer);
  }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int[] nk = new int[2];
    for (int i = 0; i < nk.length; i++){
      nk[i] = sc.nextInt();
    }
    sc.nextLine();
    int[] pn = new int[nk[0]];
	for (int i = 0; i < nk[0]; i++){
      pn[i] = sc.nextInt();
    }
    Arrays.sort(pn);
    int answer = 0;
    for (int i = 0; i < nk[1]; i++){
      answer += pn[i];
    }
    System.out.println(answer);
  } main {
    Scanner sc = new Scanner(System.in);
    int[] nk = new int[2];
    for (int i = 0; i < nk.length; i++){
      nk[i] = sc.nextInt();
    }
    sc.nextLine();
    int[] pn = new int[nk[0]];
	for (int i = 0; i < nk[0]; i++){
      pn[i] = sc.nextInt();
    }
    Arrays.sort(pn);
    int answer = 0;
    for (int i = 0; i < nk[1]; i++){
      answer += pn[i];
    }
    System.out.println(answer);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int[] nk = new int[2]; nk new int[2] 2 for (int i = 0; i < nk.length; i++){
      nk[i] = sc.nextInt();
    } int i = 0; int i = 0; i 0 i < nk.length i nk.length nk nk.length i++ i++ i {
      nk[i] = sc.nextInt();
    } {
      nk[i] = sc.nextInt();
    } nk[i] = sc.nextInt() nk[i] nk i sc.nextInt() sc.nextInt sc sc.nextLine() sc.nextLine sc int[] pn = new int[nk[0]]; pn new int[nk[0]] nk[0] nk 0 for (int i = 0; i < nk[0]; i++){
      pn[i] = sc.nextInt();
    } int i = 0; int i = 0; i 0 i < nk[0] i nk[0] nk 0 i++ i++ i {
      pn[i] = sc.nextInt();
    } {
      pn[i] = sc.nextInt();
    } pn[i] = sc.nextInt() pn[i] pn i sc.nextInt() sc.nextInt sc Arrays.sort(pn) Arrays.sort Arrays pn int answer = 0; answer 0 for (int i = 0; i < nk[1]; i++){
      answer += pn[i];
    } int i = 0; int i = 0; i 0 i < nk[1] i nk[1] nk 1 i++ i++ i {
      answer += pn[i];
    } {
      answer += pn[i];
    } answer += pn[i] answer pn[i] pn i System.out.println(answer) System.out.println System.out System System.out answer String[] args args public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int[] nk = new int[2];
    for (int i = 0; i < nk.length; i++){
      nk[i] = sc.nextInt();
    }
    sc.nextLine();
    int[] pn = new int[nk[0]];
	for (int i = 0; i < nk[0]; i++){
      pn[i] = sc.nextInt();
    }
    Arrays.sort(pn);
    int answer = 0;
    for (int i = 0; i < nk[1]; i++){
      answer += pn[i];
    }
    System.out.println(answer);
  }
} public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int[] nk = new int[2];
    for (int i = 0; i < nk.length; i++){
      nk[i] = sc.nextInt();
    }
    sc.nextLine();
    int[] pn = new int[nk[0]];
	for (int i = 0; i < nk[0]; i++){
      pn[i] = sc.nextInt();
    }
    Arrays.sort(pn);
    int answer = 0;
    for (int i = 0; i < nk[1]; i++){
      answer += pn[i];
    }
    System.out.println(answer);
  }
} Main
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int[] nk = new int[2];
    for (int i = 0; i < nk.length; i++){
      nk[i] = sc.nextInt();
    }
    sc.nextLine();
    int[] pn = new int[nk[0]];
	for (int i = 0; i < nk[0]; i++){
      pn[i] = sc.nextInt();
    }
    Arrays.sort(pn);
    int answer = 0;
    for (int i = 0; i < nk[1]; i++){
      answer += pn[i];
    }
    System.out.println(answer);
  }
}
