import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
        int b  = sc.nextInt();
        int c[] = new int[a];
        long ans = 0;
      
        for(int i = 0;i < a;i++){
          c[i] = sc.nextInt();
        }
        Arrays.sort(c);
        for(int i = 0;i < b;i++){
          ans += c[i];
        }
      
      	System.out.println(ans);
 
    }
} import java.util.*; util.* java public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
        int b  = sc.nextInt();
        int c[] = new int[a];
        long ans = 0;
      
        for(int i = 0;i < a;i++){
          c[i] = sc.nextInt();
        }
        Arrays.sort(c);
        for(int i = 0;i < b;i++){
          ans += c[i];
        }
      
      	System.out.println(ans);
 
    }
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
        int b  = sc.nextInt();
        int c[] = new int[a];
        long ans = 0;
      
        for(int i = 0;i < a;i++){
          c[i] = sc.nextInt();
        }
        Arrays.sort(c);
        for(int i = 0;i < b;i++){
          ans += c[i];
        }
      
      	System.out.println(ans);
 
    } main {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
        int b  = sc.nextInt();
        int c[] = new int[a];
        long ans = 0;
      
        for(int i = 0;i < a;i++){
          c[i] = sc.nextInt();
        }
        Arrays.sort(c);
        for(int i = 0;i < b;i++){
          ans += c[i];
        }
      
      	System.out.println(ans);
 
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc int b  = sc.nextInt(); b sc.nextInt() sc.nextInt sc int c[] = new int[a]; c new int[a] a long ans = 0; ans 0 for(int i = 0;i < a;i++){
          c[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < a i a i++ i++ i {
          c[i] = sc.nextInt();
        } {
          c[i] = sc.nextInt();
        } c[i] = sc.nextInt() c[i] c i sc.nextInt() sc.nextInt sc Arrays.sort(c) Arrays.sort Arrays c for(int i = 0;i < b;i++){
          ans += c[i];
        } int i = 0; int i = 0; i 0 i < b i b i++ i++ i {
          ans += c[i];
        } {
          ans += c[i];
        } ans += c[i] ans c[i] c i System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
        int b  = sc.nextInt();
        int c[] = new int[a];
        long ans = 0;
      
        for(int i = 0;i < a;i++){
          c[i] = sc.nextInt();
        }
        Arrays.sort(c);
        for(int i = 0;i < b;i++){
          ans += c[i];
        }
      
      	System.out.println(ans);
 
    }
} public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
        int b  = sc.nextInt();
        int c[] = new int[a];
        long ans = 0;
      
        for(int i = 0;i < a;i++){
          c[i] = sc.nextInt();
        }
        Arrays.sort(c);
        for(int i = 0;i < b;i++){
          ans += c[i];
        }
      
      	System.out.println(ans);
 
    }
} Main
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
        int b  = sc.nextInt();
        int c[] = new int[a];
        long ans = 0;
      
        for(int i = 0;i < a;i++){
          c[i] = sc.nextInt();
        }
        Arrays.sort(c);
        for(int i = 0;i < b;i++){
          ans += c[i];
        }
      
      	System.out.println(ans);
 
    }
}