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