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

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

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