import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		ArrayList<Integer> shoplist= new ArrayList<Integer>();

		for(int i=0;i<N;i++) {
			shoplist.add(sc.nextInt());
		}
		sc.close();
		Collections.sort(shoplist);

		int result = 0;
		for(int i=0;i<K;i++) {
			result = result + shoplist.get(i);
		}

		System.out.println(result);

	}


} import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		ArrayList<Integer> shoplist= new ArrayList<Integer>();

		for(int i=0;i<N;i++) {
			shoplist.add(sc.nextInt());
		}
		sc.close();
		Collections.sort(shoplist);

		int result = 0;
		for(int i=0;i<K;i++) {
			result = result + shoplist.get(i);
		}

		System.out.println(result);

	}


} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		ArrayList<Integer> shoplist= new ArrayList<Integer>();

		for(int i=0;i<N;i++) {
			shoplist.add(sc.nextInt());
		}
		sc.close();
		Collections.sort(shoplist);

		int result = 0;
		for(int i=0;i<K;i++) {
			result = result + shoplist.get(i);
		}

		System.out.println(result);

	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		ArrayList<Integer> shoplist= new ArrayList<Integer>();

		for(int i=0;i<N;i++) {
			shoplist.add(sc.nextInt());
		}
		sc.close();
		Collections.sort(shoplist);

		int result = 0;
		for(int i=0;i<K;i++) {
			result = result + shoplist.get(i);
		}

		System.out.println(result);

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int K = sc.nextInt(); K sc.nextInt() sc.nextInt sc ArrayList<Integer> shoplist= new ArrayList<Integer>(); shoplist new ArrayList<Integer>() for(int i=0;i<N;i++) {
			shoplist.add(sc.nextInt());
		} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			shoplist.add(sc.nextInt());
		} {
			shoplist.add(sc.nextInt());
		} shoplist.add(sc.nextInt()) shoplist.add shoplist sc.nextInt() sc.nextInt sc sc.close() sc.close sc Collections.sort(shoplist) Collections.sort Collections shoplist int result = 0; result 0 for(int i=0;i<K;i++) {
			result = result + shoplist.get(i);
		} int i=0; int i=0; i 0 i<K i K i++ i++ i {
			result = result + shoplist.get(i);
		} {
			result = result + shoplist.get(i);
		} result = result + shoplist.get(i) result result + shoplist.get(i) result shoplist.get(i) shoplist.get shoplist i System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		ArrayList<Integer> shoplist= new ArrayList<Integer>();

		for(int i=0;i<N;i++) {
			shoplist.add(sc.nextInt());
		}
		sc.close();
		Collections.sort(shoplist);

		int result = 0;
		for(int i=0;i<K;i++) {
			result = result + shoplist.get(i);
		}

		System.out.println(result);

	}


} public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		ArrayList<Integer> shoplist= new ArrayList<Integer>();

		for(int i=0;i<N;i++) {
			shoplist.add(sc.nextInt());
		}
		sc.close();
		Collections.sort(shoplist);

		int result = 0;
		for(int i=0;i<K;i++) {
			result = result + shoplist.get(i);
		}

		System.out.println(result);

	}


} Main
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		ArrayList<Integer> shoplist= new ArrayList<Integer>();

		for(int i=0;i<N;i++) {
			shoplist.add(sc.nextInt());
		}
		sc.close();
		Collections.sort(shoplist);

		int result = 0;
		for(int i=0;i<K;i++) {
			result = result + shoplist.get(i);
		}

		System.out.println(result);

	}


}