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

public class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        String input = stdIn.nextLine();
        int n = Integer.parseInt(input.split(" ")[0]);
        int k = Integer.parseInt(input.split(" ")[1]);

        String P = stdIn.nextLine();
        int[] p = new int[n];
        for(int i = 0 ; i < n ; i++){
            p[i] = Integer.parseInt(P.split(" ")[i]);
        }
        Arrays.sort(p);
        int ans = 0;
        for(int i = 0 ; i < k ; i++){
            ans += p[i];
        }
        System.out.println(ans);
    }
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        String input = stdIn.nextLine();
        int n = Integer.parseInt(input.split(" ")[0]);
        int k = Integer.parseInt(input.split(" ")[1]);

        String P = stdIn.nextLine();
        int[] p = new int[n];
        for(int i = 0 ; i < n ; i++){
            p[i] = Integer.parseInt(P.split(" ")[i]);
        }
        Arrays.sort(p);
        int ans = 0;
        for(int i = 0 ; i < k ; i++){
            ans += p[i];
        }
        System.out.println(ans);
    }
} Main public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        String input = stdIn.nextLine();
        int n = Integer.parseInt(input.split(" ")[0]);
        int k = Integer.parseInt(input.split(" ")[1]);

        String P = stdIn.nextLine();
        int[] p = new int[n];
        for(int i = 0 ; i < n ; i++){
            p[i] = Integer.parseInt(P.split(" ")[i]);
        }
        Arrays.sort(p);
        int ans = 0;
        for(int i = 0 ; i < k ; i++){
            ans += p[i];
        }
        System.out.println(ans);
    } main {
        Scanner stdIn = new Scanner(System.in);
        String input = stdIn.nextLine();
        int n = Integer.parseInt(input.split(" ")[0]);
        int k = Integer.parseInt(input.split(" ")[1]);

        String P = stdIn.nextLine();
        int[] p = new int[n];
        for(int i = 0 ; i < n ; i++){
            p[i] = Integer.parseInt(P.split(" ")[i]);
        }
        Arrays.sort(p);
        int ans = 0;
        for(int i = 0 ; i < k ; i++){
            ans += p[i];
        }
        System.out.println(ans);
    } Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) String input = stdIn.nextLine(); input stdIn.nextLine() stdIn.nextLine stdIn int n = Integer.parseInt(input.split(" ")[0]); n Integer.parseInt(input.split(" ")[0]) Integer.parseInt Integer input.split(" ")[0] input.split(" ") input.split input " " 0 int k = Integer.parseInt(input.split(" ")[1]); k Integer.parseInt(input.split(" ")[1]) Integer.parseInt Integer input.split(" ")[1] input.split(" ") input.split input " " 1 String P = stdIn.nextLine(); P stdIn.nextLine() stdIn.nextLine stdIn int[] p = new int[n]; p new int[n] n for(int i = 0 ; i < n ; i++){
            p[i] = Integer.parseInt(P.split(" ")[i]);
        } int i = 0 ; int i = 0 ; i 0 i < n i n i++ i++ i {
            p[i] = Integer.parseInt(P.split(" ")[i]);
        } {
            p[i] = Integer.parseInt(P.split(" ")[i]);
        } p[i] = Integer.parseInt(P.split(" ")[i]) p[i] p i Integer.parseInt(P.split(" ")[i]) Integer.parseInt Integer P.split(" ")[i] P.split(" ") P.split P " " i Arrays.sort(p) Arrays.sort Arrays p int ans = 0; ans 0 for(int i = 0 ; i < k ; i++){
            ans += p[i];
        } int i = 0 ; int i = 0 ; i 0 i < k i k i++ i++ i {
            ans += p[i];
        } {
            ans += p[i];
        } ans += p[i] ans p[i] p 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 stdIn = new Scanner(System.in);
        String input = stdIn.nextLine();
        int n = Integer.parseInt(input.split(" ")[0]);
        int k = Integer.parseInt(input.split(" ")[1]);

        String P = stdIn.nextLine();
        int[] p = new int[n];
        for(int i = 0 ; i < n ; i++){
            p[i] = Integer.parseInt(P.split(" ")[i]);
        }
        Arrays.sort(p);
        int ans = 0;
        for(int i = 0 ; i < k ; i++){
            ans += p[i];
        }
        System.out.println(ans);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        String input = stdIn.nextLine();
        int n = Integer.parseInt(input.split(" ")[0]);
        int k = Integer.parseInt(input.split(" ")[1]);

        String P = stdIn.nextLine();
        int[] p = new int[n];
        for(int i = 0 ; i < n ; i++){
            p[i] = Integer.parseInt(P.split(" ")[i]);
        }
        Arrays.sort(p);
        int ans = 0;
        for(int i = 0 ; i < k ; i++){
            ans += p[i];
        }
        System.out.println(ans);
    }
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        String input = stdIn.nextLine();
        int n = Integer.parseInt(input.split(" ")[0]);
        int k = Integer.parseInt(input.split(" ")[1]);

        String P = stdIn.nextLine();
        int[] p = new int[n];
        for(int i = 0 ; i < n ; i++){
            p[i] = Integer.parseInt(P.split(" ")[i]);
        }
        Arrays.sort(p);
        int ans = 0;
        for(int i = 0 ; i < k ; i++){
            ans += p[i];
        }
        System.out.println(ans);
    }
}