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

public class Main {
    public static void main(String[] args)
    {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int K = scanner.nextInt();
        int[] fruits = new int[N];
        for(int i=0;i<N;i++)
            fruits[i] = scanner.nextInt();
        Arrays.sort(fruits);
        int total = 0;
        for(int i=0;i<K;i++)
            total += fruits[i];
        System.out.println(total);
    }
} 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 N = scanner.nextInt();
        int K = scanner.nextInt();
        int[] fruits = new int[N];
        for(int i=0;i<N;i++)
            fruits[i] = scanner.nextInt();
        Arrays.sort(fruits);
        int total = 0;
        for(int i=0;i<K;i++)
            total += fruits[i];
        System.out.println(total);
    }
} Main public static void main(String[] args)
    {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int K = scanner.nextInt();
        int[] fruits = new int[N];
        for(int i=0;i<N;i++)
            fruits[i] = scanner.nextInt();
        Arrays.sort(fruits);
        int total = 0;
        for(int i=0;i<K;i++)
            total += fruits[i];
        System.out.println(total);
    } main {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int K = scanner.nextInt();
        int[] fruits = new int[N];
        for(int i=0;i<N;i++)
            fruits[i] = scanner.nextInt();
        Arrays.sort(fruits);
        int total = 0;
        for(int i=0;i<K;i++)
            total += fruits[i];
        System.out.println(total);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int N = scanner.nextInt(); N scanner.nextInt() scanner.nextInt scanner int K = scanner.nextInt(); K scanner.nextInt() scanner.nextInt scanner int[] fruits = new int[N]; fruits new int[N] N for(int i=0;i<N;i++)
            fruits[i] = scanner.nextInt(); int i=0; int i=0; i 0 i<N i N i++ i++ i fruits[i] = scanner.nextInt(); fruits[i] = scanner.nextInt() fruits[i] fruits i scanner.nextInt() scanner.nextInt scanner Arrays.sort(fruits) Arrays.sort Arrays fruits int total = 0; total 0 for(int i=0;i<K;i++)
            total += fruits[i]; int i=0; int i=0; i 0 i<K i K i++ i++ i total += fruits[i]; total += fruits[i] total fruits[i] fruits i System.out.println(total) System.out.println System.out System System.out total String[] args args public class Main {
    public static void main(String[] args)
    {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int K = scanner.nextInt();
        int[] fruits = new int[N];
        for(int i=0;i<N;i++)
            fruits[i] = scanner.nextInt();
        Arrays.sort(fruits);
        int total = 0;
        for(int i=0;i<K;i++)
            total += fruits[i];
        System.out.println(total);
    }
} public class Main {
    public static void main(String[] args)
    {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int K = scanner.nextInt();
        int[] fruits = new int[N];
        for(int i=0;i<N;i++)
            fruits[i] = scanner.nextInt();
        Arrays.sort(fruits);
        int total = 0;
        for(int i=0;i<K;i++)
            total += fruits[i];
        System.out.println(total);
    }
} 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 N = scanner.nextInt();
        int K = scanner.nextInt();
        int[] fruits = new int[N];
        for(int i=0;i<N;i++)
            fruits[i] = scanner.nextInt();
        Arrays.sort(fruits);
        int total = 0;
        for(int i=0;i<K;i++)
            total += fruits[i];
        System.out.println(total);
    }
}
