import java.util.Arrays;
import java.util.Scanner;

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

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