import java.util.*;
class Main {
  static Scanner scan = new Scanner(System.in);
  public static void main(String[] args) {
  	int N = scan.nextInt();
    int K = scan.nextInt();
    int[] arr = new int[N];
    takeInput(arr);
    System.out.println(minPrice(arr, K));
  }
  private static void takeInput(int[] arr) {
  	for(int i = 0; i < arr.length; i++) {
    	arr[i] = scan.nextInt();
    }
  }
  private static int minPrice(int[] arr, int K) {
  	Arrays.sort(arr);
    int sum = 0;
    for(int i = 0; i < K; i++) {
    	sum += arr[i];
    }
    return sum;
  }
} import java.util.*; util.* java class Main {
  static Scanner scan = new Scanner(System.in);
  public static void main(String[] args) {
  	int N = scan.nextInt();
    int K = scan.nextInt();
    int[] arr = new int[N];
    takeInput(arr);
    System.out.println(minPrice(arr, K));
  }
  private static void takeInput(int[] arr) {
  	for(int i = 0; i < arr.length; i++) {
    	arr[i] = scan.nextInt();
    }
  }
  private static int minPrice(int[] arr, int K) {
  	Arrays.sort(arr);
    int sum = 0;
    for(int i = 0; i < K; i++) {
    	sum += arr[i];
    }
    return sum;
  }
} Main static Scanner scan = new Scanner(System.in); scan new Scanner(System.in) public static void main(String[] args) {
  	int N = scan.nextInt();
    int K = scan.nextInt();
    int[] arr = new int[N];
    takeInput(arr);
    System.out.println(minPrice(arr, K));
  } main {
  	int N = scan.nextInt();
    int K = scan.nextInt();
    int[] arr = new int[N];
    takeInput(arr);
    System.out.println(minPrice(arr, K));
  } int N = scan.nextInt(); N scan.nextInt() scan.nextInt scan int K = scan.nextInt(); K scan.nextInt() scan.nextInt scan int[] arr = new int[N]; arr new int[N] N takeInput(arr) takeInput arr System.out.println(minPrice(arr, K)) System.out.println System.out System System.out minPrice(arr, K) minPrice arr K String[] args args private static void takeInput(int[] arr) {
  	for(int i = 0; i < arr.length; i++) {
    	arr[i] = scan.nextInt();
    }
  } takeInput {
  	for(int i = 0; i < arr.length; i++) {
    	arr[i] = scan.nextInt();
    }
  } for(int i = 0; i < arr.length; i++) {
    	arr[i] = scan.nextInt();
    } int i = 0; int i = 0; i 0 i < arr.length i arr.length arr arr.length i++ i++ i {
    	arr[i] = scan.nextInt();
    } {
    	arr[i] = scan.nextInt();
    } arr[i] = scan.nextInt() arr[i] arr i scan.nextInt() scan.nextInt scan int[] arr arr private static int minPrice(int[] arr, int K) {
  	Arrays.sort(arr);
    int sum = 0;
    for(int i = 0; i < K; i++) {
    	sum += arr[i];
    }
    return sum;
  } minPrice {
  	Arrays.sort(arr);
    int sum = 0;
    for(int i = 0; i < K; i++) {
    	sum += arr[i];
    }
    return sum;
  } Arrays.sort(arr) Arrays.sort Arrays arr int sum = 0; sum 0 for(int i = 0; i < K; i++) {
    	sum += arr[i];
    } int i = 0; int i = 0; i 0 i < K i K i++ i++ i {
    	sum += arr[i];
    } {
    	sum += arr[i];
    } sum += arr[i] sum arr[i] arr i return sum; sum int[] arr arr int K K
import java.util.*;
class Main {
  static Scanner scan = new Scanner(System.in);
  public static void main(String[] args) {
  	int N = scan.nextInt();
    int K = scan.nextInt();
    int[] arr = new int[N];
    takeInput(arr);
    System.out.println(minPrice(arr, K));
  }
  private static void takeInput(int[] arr) {
  	for(int i = 0; i < arr.length; i++) {
    	arr[i] = scan.nextInt();
    }
  }
  private static int minPrice(int[] arr, int K) {
  	Arrays.sort(arr);
    int sum = 0;
    for(int i = 0; i < K; i++) {
    	sum += arr[i];
    }
    return sum;
  }
}