import java.util.Scanner;
import java.util.Arrays;
public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int k = scan.nextInt();
    int vec[];
    vec = new int[n];
    for (int i = 0; i < n; i++){
      vec[i] = scan.nextInt();
    }
    int ans = 0;
    Arrays.sort(vec);
    for (int i = 0; i < k; i++){
      ans = ans + vec[i];
    }
    System.out.println(ans);
  }
}
     import java.util.Scanner; Scanner java.util import java.util.Arrays; Arrays java.util public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int k = scan.nextInt();
    int vec[];
    vec = new int[n];
    for (int i = 0; i < n; i++){
      vec[i] = scan.nextInt();
    }
    int ans = 0;
    Arrays.sort(vec);
    for (int i = 0; i < k; i++){
      ans = ans + vec[i];
    }
    System.out.println(ans);
  }
} Main public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int k = scan.nextInt();
    int vec[];
    vec = new int[n];
    for (int i = 0; i < n; i++){
      vec[i] = scan.nextInt();
    }
    int ans = 0;
    Arrays.sort(vec);
    for (int i = 0; i < k; i++){
      ans = ans + vec[i];
    }
    System.out.println(ans);
  } main {
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int k = scan.nextInt();
    int vec[];
    vec = new int[n];
    for (int i = 0; i < n; i++){
      vec[i] = scan.nextInt();
    }
    int ans = 0;
    Arrays.sort(vec);
    for (int i = 0; i < k; i++){
      ans = ans + vec[i];
    }
    System.out.println(ans);
  } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan int k = scan.nextInt(); k scan.nextInt() scan.nextInt scan int vec[]; vec vec = new int[n] vec new int[n] n for (int i = 0; i < n; i++){
      vec[i] = scan.nextInt();
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      vec[i] = scan.nextInt();
    } {
      vec[i] = scan.nextInt();
    } vec[i] = scan.nextInt() vec[i] vec i scan.nextInt() scan.nextInt scan int ans = 0; ans 0 Arrays.sort(vec) Arrays.sort Arrays vec for (int i = 0; i < k; i++){
      ans = ans + vec[i];
    } int i = 0; int i = 0; i 0 i < k i k i++ i++ i {
      ans = ans + vec[i];
    } {
      ans = ans + vec[i];
    } ans = ans + vec[i] ans ans + vec[i] ans vec[i] vec i System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int k = scan.nextInt();
    int vec[];
    vec = new int[n];
    for (int i = 0; i < n; i++){
      vec[i] = scan.nextInt();
    }
    int ans = 0;
    Arrays.sort(vec);
    for (int i = 0; i < k; i++){
      ans = ans + vec[i];
    }
    System.out.println(ans);
  }
} public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int k = scan.nextInt();
    int vec[];
    vec = new int[n];
    for (int i = 0; i < n; i++){
      vec[i] = scan.nextInt();
    }
    int ans = 0;
    Arrays.sort(vec);
    for (int i = 0; i < k; i++){
      ans = ans + vec[i];
    }
    System.out.println(ans);
  }
} Main
import java.util.Scanner;
import java.util.Arrays;
public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int k = scan.nextInt();
    int vec[];
    vec = new int[n];
    for (int i = 0; i < n; i++){
      vec[i] = scan.nextInt();
    }
    int ans = 0;
    Arrays.sort(vec);
    for (int i = 0; i < k; i++){
      ans = ans + vec[i];
    }
    System.out.println(ans);
  }
}
    