import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
      int[] b = new int[a];
      int c = sc.nextInt();
      int d = 0;
      for(int i = 0; i < a; i++){
      	b[i] = sc.nextInt();
      }
        for (int i = 0; i < a- 1; i++) {
            for (int j = a - 1; j > i; j--) {
                if (b[j - 1] > b[j]) {
                    // 入れ替え
                    int tmp = b[j - 1];
                    b[j - 1] = b[j];
                    b[j] = tmp;
                }
             }
        }
      for(int i = 0; i < c; i++){
      	d += b[i];
      }
  
      System.out.println(d);
	}
} 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 = new int[a];
      int c = sc.nextInt();
      int d = 0;
      for(int i = 0; i < a; i++){
      	b[i] = sc.nextInt();
      }
        for (int i = 0; i < a- 1; i++) {
            for (int j = a - 1; j > i; j--) {
                if (b[j - 1] > b[j]) {
                    // 入れ替え
                    int tmp = b[j - 1];
                    b[j - 1] = b[j];
                    b[j] = tmp;
                }
             }
        }
      for(int i = 0; i < c; i++){
      	d += b[i];
      }
  
      System.out.println(d);
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
      int[] b = new int[a];
      int c = sc.nextInt();
      int d = 0;
      for(int i = 0; i < a; i++){
      	b[i] = sc.nextInt();
      }
        for (int i = 0; i < a- 1; i++) {
            for (int j = a - 1; j > i; j--) {
                if (b[j - 1] > b[j]) {
                    // 入れ替え
                    int tmp = b[j - 1];
                    b[j - 1] = b[j];
                    b[j] = tmp;
                }
             }
        }
      for(int i = 0; i < c; i++){
      	d += b[i];
      }
  
      System.out.println(d);
	} main {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
      int[] b = new int[a];
      int c = sc.nextInt();
      int d = 0;
      for(int i = 0; i < a; i++){
      	b[i] = sc.nextInt();
      }
        for (int i = 0; i < a- 1; i++) {
            for (int j = a - 1; j > i; j--) {
                if (b[j - 1] > b[j]) {
                    // 入れ替え
                    int tmp = b[j - 1];
                    b[j - 1] = b[j];
                    b[j] = tmp;
                }
             }
        }
      for(int i = 0; i < c; i++){
      	d += b[i];
      }
  
      System.out.println(d);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc int[] b = new int[a]; b new int[a] a int c = sc.nextInt(); c sc.nextInt() sc.nextInt sc int d = 0; d 0 for(int i = 0; i < a; i++){
      	b[i] = sc.nextInt();
      } int i = 0; int i = 0; i 0 i < a i a i++ i++ i {
      	b[i] = sc.nextInt();
      } {
      	b[i] = sc.nextInt();
      } b[i] = sc.nextInt() b[i] b i sc.nextInt() sc.nextInt sc for (int i = 0; i < a- 1; i++) {
            for (int j = a - 1; j > i; j--) {
                if (b[j - 1] > b[j]) {
                    // 入れ替え
                    int tmp = b[j - 1];
                    b[j - 1] = b[j];
                    b[j] = tmp;
                }
             }
        } int i = 0; int i = 0; i 0 i < a- 1 i a- 1 a 1 i++ i++ i {
            for (int j = a - 1; j > i; j--) {
                if (b[j - 1] > b[j]) {
                    // 入れ替え
                    int tmp = b[j - 1];
                    b[j - 1] = b[j];
                    b[j] = tmp;
                }
             }
        } {
            for (int j = a - 1; j > i; j--) {
                if (b[j - 1] > b[j]) {
                    // 入れ替え
                    int tmp = b[j - 1];
                    b[j - 1] = b[j];
                    b[j] = tmp;
                }
             }
        } for (int j = a - 1; j > i; j--) {
                if (b[j - 1] > b[j]) {
                    // 入れ替え
                    int tmp = b[j - 1];
                    b[j - 1] = b[j];
                    b[j] = tmp;
                }
             } int j = a - 1; int j = a - 1; j a - 1 a 1 j > i j i j-- j-- j {
                if (b[j - 1] > b[j]) {
                    // 入れ替え
                    int tmp = b[j - 1];
                    b[j - 1] = b[j];
                    b[j] = tmp;
                }
             } {
                if (b[j - 1] > b[j]) {
                    // 入れ替え
                    int tmp = b[j - 1];
                    b[j - 1] = b[j];
                    b[j] = tmp;
                }
             } if (b[j - 1] > b[j]) {
                    // 入れ替え
                    int tmp = b[j - 1];
                    b[j - 1] = b[j];
                    b[j] = tmp;
                } b[j - 1] > b[j] b[j - 1] b j - 1 j 1 b[j] b j {
                    // 入れ替え
                    int tmp = b[j - 1];
                    b[j - 1] = b[j];
                    b[j] = tmp;
                } int tmp = b[j - 1]; tmp b[j - 1] b j - 1 j 1 b[j - 1] = b[j] b[j - 1] b j - 1 j 1 b[j] b j b[j] = tmp b[j] b j tmp for(int i = 0; i < c; i++){
      	d += b[i];
      } int i = 0; int i = 0; i 0 i < c i c i++ i++ i {
      	d += b[i];
      } {
      	d += b[i];
      } d += b[i] d b[i] b i System.out.println(d) System.out.println System.out System System.out d String[] args args public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
      int[] b = new int[a];
      int c = sc.nextInt();
      int d = 0;
      for(int i = 0; i < a; i++){
      	b[i] = sc.nextInt();
      }
        for (int i = 0; i < a- 1; i++) {
            for (int j = a - 1; j > i; j--) {
                if (b[j - 1] > b[j]) {
                    // 入れ替え
                    int tmp = b[j - 1];
                    b[j - 1] = b[j];
                    b[j] = tmp;
                }
             }
        }
      for(int i = 0; i < c; i++){
      	d += b[i];
      }
  
      System.out.println(d);
	}
} public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
      int[] b = new int[a];
      int c = sc.nextInt();
      int d = 0;
      for(int i = 0; i < a; i++){
      	b[i] = sc.nextInt();
      }
        for (int i = 0; i < a- 1; i++) {
            for (int j = a - 1; j > i; j--) {
                if (b[j - 1] > b[j]) {
                    // 入れ替え
                    int tmp = b[j - 1];
                    b[j - 1] = b[j];
                    b[j] = tmp;
                }
             }
        }
      for(int i = 0; i < c; i++){
      	d += b[i];
      }
  
      System.out.println(d);
	}
} 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 = new int[a];
      int c = sc.nextInt();
      int d = 0;
      for(int i = 0; i < a; i++){
      	b[i] = sc.nextInt();
      }
        for (int i = 0; i < a- 1; i++) {
            for (int j = a - 1; j > i; j--) {
                if (b[j - 1] > b[j]) {
                    // 入れ替え
                    int tmp = b[j - 1];
                    b[j - 1] = b[j];
                    b[j] = tmp;
                }
             }
        }
      for(int i = 0; i < c; i++){
      	d += b[i];
      }
  
      System.out.println(d);
	}
}