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

public class Main {


    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int[] num = new int[1000];
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        for(int i = 0;i < 1000;i++)
            num[i] = Integer.MAX_VALUE;
        for(int i = 0;i < n;i++)
            num[i] = scanner.nextInt();
        Arrays.sort(num);
        int sum = 0;
        for(int i = 0;i < k ;i++)
            sum += num[i];
        System.out.println(sum);


    }
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {


    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int[] num = new int[1000];
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        for(int i = 0;i < 1000;i++)
            num[i] = Integer.MAX_VALUE;
        for(int i = 0;i < n;i++)
            num[i] = scanner.nextInt();
        Arrays.sort(num);
        int sum = 0;
        for(int i = 0;i < k ;i++)
            sum += num[i];
        System.out.println(sum);


    }
} Main public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int[] num = new int[1000];
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        for(int i = 0;i < 1000;i++)
            num[i] = Integer.MAX_VALUE;
        for(int i = 0;i < n;i++)
            num[i] = scanner.nextInt();
        Arrays.sort(num);
        int sum = 0;
        for(int i = 0;i < k ;i++)
            sum += num[i];
        System.out.println(sum);


    } main {

        Scanner scanner = new Scanner(System.in);
        int[] num = new int[1000];
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        for(int i = 0;i < 1000;i++)
            num[i] = Integer.MAX_VALUE;
        for(int i = 0;i < n;i++)
            num[i] = scanner.nextInt();
        Arrays.sort(num);
        int sum = 0;
        for(int i = 0;i < k ;i++)
            sum += num[i];
        System.out.println(sum);


    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int[] num = new int[1000]; num new int[1000] 1000 int n = scanner.nextInt(); n scanner.nextInt() scanner.nextInt scanner int k = scanner.nextInt(); k scanner.nextInt() scanner.nextInt scanner for(int i = 0;i < 1000;i++)
            num[i] = Integer.MAX_VALUE; int i = 0; int i = 0; i 0 i < 1000 i 1000 i++ i++ i num[i] = Integer.MAX_VALUE; num[i] = Integer.MAX_VALUE num[i] num i Integer.MAX_VALUE Integer Integer.MAX_VALUE for(int i = 0;i < n;i++)
            num[i] = scanner.nextInt(); int i = 0; int i = 0; i 0 i < n i n i++ i++ i num[i] = scanner.nextInt(); num[i] = scanner.nextInt() num[i] num i scanner.nextInt() scanner.nextInt scanner Arrays.sort(num) Arrays.sort Arrays num int sum = 0; sum 0 for(int i = 0;i < k ;i++)
            sum += num[i]; int i = 0; int i = 0; i 0 i < k i k i++ i++ i sum += num[i]; sum += num[i] sum num[i] num i System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {


    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int[] num = new int[1000];
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        for(int i = 0;i < 1000;i++)
            num[i] = Integer.MAX_VALUE;
        for(int i = 0;i < n;i++)
            num[i] = scanner.nextInt();
        Arrays.sort(num);
        int sum = 0;
        for(int i = 0;i < k ;i++)
            sum += num[i];
        System.out.println(sum);


    }
} public class Main {


    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int[] num = new int[1000];
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        for(int i = 0;i < 1000;i++)
            num[i] = Integer.MAX_VALUE;
        for(int i = 0;i < n;i++)
            num[i] = scanner.nextInt();
        Arrays.sort(num);
        int sum = 0;
        for(int i = 0;i < k ;i++)
            sum += num[i];
        System.out.println(sum);


    }
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {


    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int[] num = new int[1000];
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        for(int i = 0;i < 1000;i++)
            num[i] = Integer.MAX_VALUE;
        for(int i = 0;i < n;i++)
            num[i] = scanner.nextInt();
        Arrays.sort(num);
        int sum = 0;
        for(int i = 0;i < k ;i++)
            sum += num[i];
        System.out.println(sum);


    }
}
