
import java.util.Arrays;
import java.util.Scanner;
public class Main {

    static void solve(int[] arr, int numberOfBrokeAss) {
      Arrays.sort(arr);
      int result = 0;
      for(int i = 0; i<numberOfBrokeAss; i++){
        result+=arr[i];
      }
      System.out.println(result);
    }

    public static void main(String[] args) {
            Scanner in = new Scanner(System.in);
            int n = in.nextInt();
            int parameter = in.nextInt();
            int[] arr = new int[n];
            for (int i = 0; i < n ; i++) {
            	arr[i] = in.nextInt();
        	}
      		solve(arr,parameter);

    }
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {

    static void solve(int[] arr, int numberOfBrokeAss) {
      Arrays.sort(arr);
      int result = 0;
      for(int i = 0; i<numberOfBrokeAss; i++){
        result+=arr[i];
      }
      System.out.println(result);
    }

    public static void main(String[] args) {
            Scanner in = new Scanner(System.in);
            int n = in.nextInt();
            int parameter = in.nextInt();
            int[] arr = new int[n];
            for (int i = 0; i < n ; i++) {
            	arr[i] = in.nextInt();
        	}
      		solve(arr,parameter);

    }
} Main static void solve(int[] arr, int numberOfBrokeAss) {
      Arrays.sort(arr);
      int result = 0;
      for(int i = 0; i<numberOfBrokeAss; i++){
        result+=arr[i];
      }
      System.out.println(result);
    } solve {
      Arrays.sort(arr);
      int result = 0;
      for(int i = 0; i<numberOfBrokeAss; i++){
        result+=arr[i];
      }
      System.out.println(result);
    } Arrays.sort(arr) Arrays.sort Arrays arr int result = 0; result 0 for(int i = 0; i<numberOfBrokeAss; i++){
        result+=arr[i];
      } int i = 0; int i = 0; i 0 i<numberOfBrokeAss i numberOfBrokeAss i++ i++ i {
        result+=arr[i];
      } {
        result+=arr[i];
      } result+=arr[i] result arr[i] arr i System.out.println(result) System.out.println System.out System System.out result int[] arr arr int numberOfBrokeAss numberOfBrokeAss public static void main(String[] args) {
            Scanner in = new Scanner(System.in);
            int n = in.nextInt();
            int parameter = in.nextInt();
            int[] arr = new int[n];
            for (int i = 0; i < n ; i++) {
            	arr[i] = in.nextInt();
        	}
      		solve(arr,parameter);

    } main {
            Scanner in = new Scanner(System.in);
            int n = in.nextInt();
            int parameter = in.nextInt();
            int[] arr = new int[n];
            for (int i = 0; i < n ; i++) {
            	arr[i] = in.nextInt();
        	}
      		solve(arr,parameter);

    } Scanner in = new Scanner(System.in); in new Scanner(System.in) int n = in.nextInt(); n in.nextInt() in.nextInt in int parameter = in.nextInt(); parameter in.nextInt() in.nextInt in int[] arr = new int[n]; arr new int[n] n for (int i = 0; i < n ; i++) {
            	arr[i] = in.nextInt();
        	} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            	arr[i] = in.nextInt();
        	} {
            	arr[i] = in.nextInt();
        	} arr[i] = in.nextInt() arr[i] arr i in.nextInt() in.nextInt in solve(arr,parameter) solve arr parameter String[] args args public class Main {

    static void solve(int[] arr, int numberOfBrokeAss) {
      Arrays.sort(arr);
      int result = 0;
      for(int i = 0; i<numberOfBrokeAss; i++){
        result+=arr[i];
      }
      System.out.println(result);
    }

    public static void main(String[] args) {
            Scanner in = new Scanner(System.in);
            int n = in.nextInt();
            int parameter = in.nextInt();
            int[] arr = new int[n];
            for (int i = 0; i < n ; i++) {
            	arr[i] = in.nextInt();
        	}
      		solve(arr,parameter);

    }
} public class Main {

    static void solve(int[] arr, int numberOfBrokeAss) {
      Arrays.sort(arr);
      int result = 0;
      for(int i = 0; i<numberOfBrokeAss; i++){
        result+=arr[i];
      }
      System.out.println(result);
    }

    public static void main(String[] args) {
            Scanner in = new Scanner(System.in);
            int n = in.nextInt();
            int parameter = in.nextInt();
            int[] arr = new int[n];
            for (int i = 0; i < n ; i++) {
            	arr[i] = in.nextInt();
        	}
      		solve(arr,parameter);

    }
} Main

import java.util.Arrays;
import java.util.Scanner;
public class Main {

    static void solve(int[] arr, int numberOfBrokeAss) {
      Arrays.sort(arr);
      int result = 0;
      for(int i = 0; i<numberOfBrokeAss; i++){
        result+=arr[i];
      }
      System.out.println(result);
    }

    public static void main(String[] args) {
            Scanner in = new Scanner(System.in);
            int n = in.nextInt();
            int parameter = in.nextInt();
            int[] arr = new int[n];
            for (int i = 0; i < n ; i++) {
            	arr[i] = in.nextInt();
        	}
      		solve(arr,parameter);

    }
}