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

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    //input
    int n = sc.nextInt();
    int k = sc.nextInt();
    ArrayList<Integer> intArray = new ArrayList<Integer>();
    for(int i = 0; i < n; i++){
      intArray.add(sc.nextInt());
    }

    //output
    //find smallest value
    int total = 0;
    for(int i = 0; i < k; i++){ //repeat k times
      int smallestInt = intArray.get(0);
      int smallestIntLocation = 0;
      for(int j = 0; j < intArray.size(); j++){
        if( intArray.get(j) < smallestInt ){
          smallestInt = intArray.get(j);
          smallestIntLocation = j;
        }
      }
      total += smallestInt;
      intArray.remove(smallestIntLocation);
    }
    System.out.println(total);

  }
} import java.util.Scanner; Scanner java.util import java.util.ArrayList; ArrayList java.util public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    //input
    int n = sc.nextInt();
    int k = sc.nextInt();
    ArrayList<Integer> intArray = new ArrayList<Integer>();
    for(int i = 0; i < n; i++){
      intArray.add(sc.nextInt());
    }

    //output
    //find smallest value
    int total = 0;
    for(int i = 0; i < k; i++){ //repeat k times
      int smallestInt = intArray.get(0);
      int smallestIntLocation = 0;
      for(int j = 0; j < intArray.size(); j++){
        if( intArray.get(j) < smallestInt ){
          smallestInt = intArray.get(j);
          smallestIntLocation = j;
        }
      }
      total += smallestInt;
      intArray.remove(smallestIntLocation);
    }
    System.out.println(total);

  }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    //input
    int n = sc.nextInt();
    int k = sc.nextInt();
    ArrayList<Integer> intArray = new ArrayList<Integer>();
    for(int i = 0; i < n; i++){
      intArray.add(sc.nextInt());
    }

    //output
    //find smallest value
    int total = 0;
    for(int i = 0; i < k; i++){ //repeat k times
      int smallestInt = intArray.get(0);
      int smallestIntLocation = 0;
      for(int j = 0; j < intArray.size(); j++){
        if( intArray.get(j) < smallestInt ){
          smallestInt = intArray.get(j);
          smallestIntLocation = j;
        }
      }
      total += smallestInt;
      intArray.remove(smallestIntLocation);
    }
    System.out.println(total);

  } main {
    Scanner sc = new Scanner(System.in);

    //input
    int n = sc.nextInt();
    int k = sc.nextInt();
    ArrayList<Integer> intArray = new ArrayList<Integer>();
    for(int i = 0; i < n; i++){
      intArray.add(sc.nextInt());
    }

    //output
    //find smallest value
    int total = 0;
    for(int i = 0; i < k; i++){ //repeat k times
      int smallestInt = intArray.get(0);
      int smallestIntLocation = 0;
      for(int j = 0; j < intArray.size(); j++){
        if( intArray.get(j) < smallestInt ){
          smallestInt = intArray.get(j);
          smallestIntLocation = j;
        }
      }
      total += smallestInt;
      intArray.remove(smallestIntLocation);
    }
    System.out.println(total);

  } 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> intArray = new ArrayList<Integer>(); intArray new ArrayList<Integer>() for(int i = 0; i < n; i++){
      intArray.add(sc.nextInt());
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      intArray.add(sc.nextInt());
    } {
      intArray.add(sc.nextInt());
    } intArray.add(sc.nextInt()) intArray.add intArray sc.nextInt() sc.nextInt sc int total = 0; total 0 for(int i = 0; i < k; i++){ //repeat k times
      int smallestInt = intArray.get(0);
      int smallestIntLocation = 0;
      for(int j = 0; j < intArray.size(); j++){
        if( intArray.get(j) < smallestInt ){
          smallestInt = intArray.get(j);
          smallestIntLocation = j;
        }
      }
      total += smallestInt;
      intArray.remove(smallestIntLocation);
    } int i = 0; int i = 0; i 0 i < k i k i++ i++ i { //repeat k times
      int smallestInt = intArray.get(0);
      int smallestIntLocation = 0;
      for(int j = 0; j < intArray.size(); j++){
        if( intArray.get(j) < smallestInt ){
          smallestInt = intArray.get(j);
          smallestIntLocation = j;
        }
      }
      total += smallestInt;
      intArray.remove(smallestIntLocation);
    } { //repeat k times
      int smallestInt = intArray.get(0);
      int smallestIntLocation = 0;
      for(int j = 0; j < intArray.size(); j++){
        if( intArray.get(j) < smallestInt ){
          smallestInt = intArray.get(j);
          smallestIntLocation = j;
        }
      }
      total += smallestInt;
      intArray.remove(smallestIntLocation);
    } int smallestInt = intArray.get(0); smallestInt intArray.get(0) intArray.get intArray 0 int smallestIntLocation = 0; smallestIntLocation 0 for(int j = 0; j < intArray.size(); j++){
        if( intArray.get(j) < smallestInt ){
          smallestInt = intArray.get(j);
          smallestIntLocation = j;
        }
      } int j = 0; int j = 0; j 0 j < intArray.size() j intArray.size() intArray.size intArray j++ j++ j {
        if( intArray.get(j) < smallestInt ){
          smallestInt = intArray.get(j);
          smallestIntLocation = j;
        }
      } {
        if( intArray.get(j) < smallestInt ){
          smallestInt = intArray.get(j);
          smallestIntLocation = j;
        }
      } if( intArray.get(j) < smallestInt ){
          smallestInt = intArray.get(j);
          smallestIntLocation = j;
        } intArray.get(j) < smallestInt intArray.get(j) intArray.get intArray j smallestInt {
          smallestInt = intArray.get(j);
          smallestIntLocation = j;
        } smallestInt = intArray.get(j) smallestInt intArray.get(j) intArray.get intArray j smallestIntLocation = j smallestIntLocation j total += smallestInt total smallestInt intArray.remove(smallestIntLocation) intArray.remove intArray smallestIntLocation System.out.println(total) System.out.println System.out System System.out total String[] args args public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    //input
    int n = sc.nextInt();
    int k = sc.nextInt();
    ArrayList<Integer> intArray = new ArrayList<Integer>();
    for(int i = 0; i < n; i++){
      intArray.add(sc.nextInt());
    }

    //output
    //find smallest value
    int total = 0;
    for(int i = 0; i < k; i++){ //repeat k times
      int smallestInt = intArray.get(0);
      int smallestIntLocation = 0;
      for(int j = 0; j < intArray.size(); j++){
        if( intArray.get(j) < smallestInt ){
          smallestInt = intArray.get(j);
          smallestIntLocation = j;
        }
      }
      total += smallestInt;
      intArray.remove(smallestIntLocation);
    }
    System.out.println(total);

  }
} public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    //input
    int n = sc.nextInt();
    int k = sc.nextInt();
    ArrayList<Integer> intArray = new ArrayList<Integer>();
    for(int i = 0; i < n; i++){
      intArray.add(sc.nextInt());
    }

    //output
    //find smallest value
    int total = 0;
    for(int i = 0; i < k; i++){ //repeat k times
      int smallestInt = intArray.get(0);
      int smallestIntLocation = 0;
      for(int j = 0; j < intArray.size(); j++){
        if( intArray.get(j) < smallestInt ){
          smallestInt = intArray.get(j);
          smallestIntLocation = j;
        }
      }
      total += smallestInt;
      intArray.remove(smallestIntLocation);
    }
    System.out.println(total);

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

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    //input
    int n = sc.nextInt();
    int k = sc.nextInt();
    ArrayList<Integer> intArray = new ArrayList<Integer>();
    for(int i = 0; i < n; i++){
      intArray.add(sc.nextInt());
    }

    //output
    //find smallest value
    int total = 0;
    for(int i = 0; i < k; i++){ //repeat k times
      int smallestInt = intArray.get(0);
      int smallestIntLocation = 0;
      for(int j = 0; j < intArray.size(); j++){
        if( intArray.get(j) < smallestInt ){
          smallestInt = intArray.get(j);
          smallestIntLocation = j;
        }
      }
      total += smallestInt;
      intArray.remove(smallestIntLocation);
    }
    System.out.println(total);

  }
}
