import java.util.ArrayList;
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> arrayList = new ArrayList<Integer>();
       for(int i=0;i<n;i++){
           arrayList.add(sc.nextInt());
       }
       int sum = 0;
       for(int i=0;i<k;i++){
           int idx = 0;
           int min = 999999;
           for(int j=0;j<arrayList.size();j++){
               if(arrayList.get(j)<min){
                   idx = j;
                   min = arrayList.get(j);
               }
           }
           sum += arrayList.get(idx);
           arrayList.remove(idx);
       }

        System.out.println(sum);
    }

} import java.util.ArrayList; ArrayList 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> arrayList = new ArrayList<Integer>();
       for(int i=0;i<n;i++){
           arrayList.add(sc.nextInt());
       }
       int sum = 0;
       for(int i=0;i<k;i++){
           int idx = 0;
           int min = 999999;
           for(int j=0;j<arrayList.size();j++){
               if(arrayList.get(j)<min){
                   idx = j;
                   min = arrayList.get(j);
               }
           }
           sum += arrayList.get(idx);
           arrayList.remove(idx);
       }

        System.out.println(sum);
    }

} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
       int n = sc.nextInt();
       int k = sc.nextInt();
       ArrayList<Integer> arrayList = new ArrayList<Integer>();
       for(int i=0;i<n;i++){
           arrayList.add(sc.nextInt());
       }
       int sum = 0;
       for(int i=0;i<k;i++){
           int idx = 0;
           int min = 999999;
           for(int j=0;j<arrayList.size();j++){
               if(arrayList.get(j)<min){
                   idx = j;
                   min = arrayList.get(j);
               }
           }
           sum += arrayList.get(idx);
           arrayList.remove(idx);
       }

        System.out.println(sum);
    } main {
        Scanner sc = new Scanner(System.in);
       int n = sc.nextInt();
       int k = sc.nextInt();
       ArrayList<Integer> arrayList = new ArrayList<Integer>();
       for(int i=0;i<n;i++){
           arrayList.add(sc.nextInt());
       }
       int sum = 0;
       for(int i=0;i<k;i++){
           int idx = 0;
           int min = 999999;
           for(int j=0;j<arrayList.size();j++){
               if(arrayList.get(j)<min){
                   idx = j;
                   min = arrayList.get(j);
               }
           }
           sum += arrayList.get(idx);
           arrayList.remove(idx);
       }

        System.out.println(sum);
    } 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> arrayList = new ArrayList<Integer>(); arrayList new ArrayList<Integer>() for(int i=0;i<n;i++){
           arrayList.add(sc.nextInt());
       } int i=0; int i=0; i 0 i<n i n i++ i++ i {
           arrayList.add(sc.nextInt());
       } {
           arrayList.add(sc.nextInt());
       } arrayList.add(sc.nextInt()) arrayList.add arrayList sc.nextInt() sc.nextInt sc int sum = 0; sum 0 for(int i=0;i<k;i++){
           int idx = 0;
           int min = 999999;
           for(int j=0;j<arrayList.size();j++){
               if(arrayList.get(j)<min){
                   idx = j;
                   min = arrayList.get(j);
               }
           }
           sum += arrayList.get(idx);
           arrayList.remove(idx);
       } int i=0; int i=0; i 0 i<k i k i++ i++ i {
           int idx = 0;
           int min = 999999;
           for(int j=0;j<arrayList.size();j++){
               if(arrayList.get(j)<min){
                   idx = j;
                   min = arrayList.get(j);
               }
           }
           sum += arrayList.get(idx);
           arrayList.remove(idx);
       } {
           int idx = 0;
           int min = 999999;
           for(int j=0;j<arrayList.size();j++){
               if(arrayList.get(j)<min){
                   idx = j;
                   min = arrayList.get(j);
               }
           }
           sum += arrayList.get(idx);
           arrayList.remove(idx);
       } int idx = 0; idx 0 int min = 999999; min 999999 for(int j=0;j<arrayList.size();j++){
               if(arrayList.get(j)<min){
                   idx = j;
                   min = arrayList.get(j);
               }
           } int j=0; int j=0; j 0 j<arrayList.size() j arrayList.size() arrayList.size arrayList j++ j++ j {
               if(arrayList.get(j)<min){
                   idx = j;
                   min = arrayList.get(j);
               }
           } {
               if(arrayList.get(j)<min){
                   idx = j;
                   min = arrayList.get(j);
               }
           } if(arrayList.get(j)<min){
                   idx = j;
                   min = arrayList.get(j);
               } arrayList.get(j)<min arrayList.get(j) arrayList.get arrayList j min {
                   idx = j;
                   min = arrayList.get(j);
               } idx = j idx j min = arrayList.get(j) min arrayList.get(j) arrayList.get arrayList j sum += arrayList.get(idx) sum arrayList.get(idx) arrayList.get arrayList idx arrayList.remove(idx) arrayList.remove arrayList idx System.out.println(sum) System.out.println System.out System System.out sum 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> arrayList = new ArrayList<Integer>();
       for(int i=0;i<n;i++){
           arrayList.add(sc.nextInt());
       }
       int sum = 0;
       for(int i=0;i<k;i++){
           int idx = 0;
           int min = 999999;
           for(int j=0;j<arrayList.size();j++){
               if(arrayList.get(j)<min){
                   idx = j;
                   min = arrayList.get(j);
               }
           }
           sum += arrayList.get(idx);
           arrayList.remove(idx);
       }

        System.out.println(sum);
    }

} 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> arrayList = new ArrayList<Integer>();
       for(int i=0;i<n;i++){
           arrayList.add(sc.nextInt());
       }
       int sum = 0;
       for(int i=0;i<k;i++){
           int idx = 0;
           int min = 999999;
           for(int j=0;j<arrayList.size();j++){
               if(arrayList.get(j)<min){
                   idx = j;
                   min = arrayList.get(j);
               }
           }
           sum += arrayList.get(idx);
           arrayList.remove(idx);
       }

        System.out.println(sum);
    }

} Main
import java.util.ArrayList;
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> arrayList = new ArrayList<Integer>();
       for(int i=0;i<n;i++){
           arrayList.add(sc.nextInt());
       }
       int sum = 0;
       for(int i=0;i<k;i++){
           int idx = 0;
           int min = 999999;
           for(int j=0;j<arrayList.size();j++){
               if(arrayList.get(j)<min){
                   idx = j;
                   min = arrayList.get(j);
               }
           }
           sum += arrayList.get(idx);
           arrayList.remove(idx);
       }

        System.out.println(sum);
    }

}
