import java.util.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int num = sc.nextInt();
        int BuyNum = sc.nextInt();
        int ans = 0;
        int[] price = new int[num];
        for (int i = 0; i < num; i++){
            price[i] = sc.nextInt();
        }
      	Arrays.sort(price);
        for (int i = 0; i < BuyNum; i++) {
            ans += price[i];
        }
        System.out.println(ans);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int num = sc.nextInt();
        int BuyNum = sc.nextInt();
        int ans = 0;
        int[] price = new int[num];
        for (int i = 0; i < num; i++){
            price[i] = sc.nextInt();
        }
      	Arrays.sort(price);
        for (int i = 0; i < BuyNum; i++) {
            ans += price[i];
        }
        System.out.println(ans);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int num = sc.nextInt();
        int BuyNum = sc.nextInt();
        int ans = 0;
        int[] price = new int[num];
        for (int i = 0; i < num; i++){
            price[i] = sc.nextInt();
        }
      	Arrays.sort(price);
        for (int i = 0; i < BuyNum; i++) {
            ans += price[i];
        }
        System.out.println(ans);
    } main {
        Scanner sc = new Scanner(System.in);
        
        int num = sc.nextInt();
        int BuyNum = sc.nextInt();
        int ans = 0;
        int[] price = new int[num];
        for (int i = 0; i < num; i++){
            price[i] = sc.nextInt();
        }
      	Arrays.sort(price);
        for (int i = 0; i < BuyNum; i++) {
            ans += price[i];
        }
        System.out.println(ans);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int num = sc.nextInt(); num sc.nextInt() sc.nextInt sc int BuyNum = sc.nextInt(); BuyNum sc.nextInt() sc.nextInt sc int ans = 0; ans 0 int[] price = new int[num]; price new int[num] num for (int i = 0; i < num; i++){
            price[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < num i num i++ i++ i {
            price[i] = sc.nextInt();
        } {
            price[i] = sc.nextInt();
        } price[i] = sc.nextInt() price[i] price i sc.nextInt() sc.nextInt sc Arrays.sort(price) Arrays.sort Arrays price for (int i = 0; i < BuyNum; i++) {
            ans += price[i];
        } int i = 0; int i = 0; i 0 i < BuyNum i BuyNum i++ i++ i {
            ans += price[i];
        } {
            ans += price[i];
        } ans += price[i] ans price[i] price 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 sc = new Scanner(System.in);
        
        int num = sc.nextInt();
        int BuyNum = sc.nextInt();
        int ans = 0;
        int[] price = new int[num];
        for (int i = 0; i < num; i++){
            price[i] = sc.nextInt();
        }
      	Arrays.sort(price);
        for (int i = 0; i < BuyNum; i++) {
            ans += price[i];
        }
        System.out.println(ans);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int num = sc.nextInt();
        int BuyNum = sc.nextInt();
        int ans = 0;
        int[] price = new int[num];
        for (int i = 0; i < num; i++){
            price[i] = sc.nextInt();
        }
      	Arrays.sort(price);
        for (int i = 0; i < BuyNum; i++) {
            ans += price[i];
        }
        System.out.println(ans);
    }
} Main
import java.util.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int num = sc.nextInt();
        int BuyNum = sc.nextInt();
        int ans = 0;
        int[] price = new int[num];
        for (int i = 0; i < num; i++){
            price[i] = sc.nextInt();
        }
      	Arrays.sort(price);
        for (int i = 0; i < BuyNum; i++) {
            ans += price[i];
        }
        System.out.println(ans);
    }
}
