import java.util.*;

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

class Main
{
    public  static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int k = sc.nextInt();
        
        int[] array = new int[n];
        for (int i = 0; i < array.length; i++) {
            array[i] = sc.nextInt();
        }
        
        Arrays.sort(array);
        
        int money = 0;
        for (int i = 0; i < k; i++) {
            money += array[i];
        }
        
        System.out.println(money);
    }
}