import java.util.Scanner;
import java.util.Arrays;
public class Main{
 public static void main(String[] args) {
   Scanner kbd =new Scanner(System.in);
   int n =kbd.nextInt();
   int k =kbd.nextInt();
   int[] A= new int[n];
   for(int i=0;i<n;i++){
     A[i]=kbd.nextInt();
   }

   Arrays.sort(A);
   int x=0;
   for(int i=0;i<k;i++){
     x=x+A[i];
   }
   System.out.println(x);
 }
} import java.util.Scanner; Scanner java.util import java.util.Arrays; Arrays java.util public class Main{
 public static void main(String[] args) {
   Scanner kbd =new Scanner(System.in);
   int n =kbd.nextInt();
   int k =kbd.nextInt();
   int[] A= new int[n];
   for(int i=0;i<n;i++){
     A[i]=kbd.nextInt();
   }

   Arrays.sort(A);
   int x=0;
   for(int i=0;i<k;i++){
     x=x+A[i];
   }
   System.out.println(x);
 }
} Main public static void main(String[] args) {
   Scanner kbd =new Scanner(System.in);
   int n =kbd.nextInt();
   int k =kbd.nextInt();
   int[] A= new int[n];
   for(int i=0;i<n;i++){
     A[i]=kbd.nextInt();
   }

   Arrays.sort(A);
   int x=0;
   for(int i=0;i<k;i++){
     x=x+A[i];
   }
   System.out.println(x);
 } main {
   Scanner kbd =new Scanner(System.in);
   int n =kbd.nextInt();
   int k =kbd.nextInt();
   int[] A= new int[n];
   for(int i=0;i<n;i++){
     A[i]=kbd.nextInt();
   }

   Arrays.sort(A);
   int x=0;
   for(int i=0;i<k;i++){
     x=x+A[i];
   }
   System.out.println(x);
 } Scanner kbd =new Scanner(System.in); kbd new Scanner(System.in) int n =kbd.nextInt(); n kbd.nextInt() kbd.nextInt kbd int k =kbd.nextInt(); k kbd.nextInt() kbd.nextInt kbd int[] A= new int[n]; A new int[n] n for(int i=0;i<n;i++){
     A[i]=kbd.nextInt();
   } int i=0; int i=0; i 0 i<n i n i++ i++ i {
     A[i]=kbd.nextInt();
   } {
     A[i]=kbd.nextInt();
   } A[i]=kbd.nextInt() A[i] A i kbd.nextInt() kbd.nextInt kbd Arrays.sort(A) Arrays.sort Arrays A int x=0; x 0 for(int i=0;i<k;i++){
     x=x+A[i];
   } int i=0; int i=0; i 0 i<k i k i++ i++ i {
     x=x+A[i];
   } {
     x=x+A[i];
   } x=x+A[i] x x+A[i] x A[i] A i System.out.println(x) System.out.println System.out System System.out x String[] args args public class Main{
 public static void main(String[] args) {
   Scanner kbd =new Scanner(System.in);
   int n =kbd.nextInt();
   int k =kbd.nextInt();
   int[] A= new int[n];
   for(int i=0;i<n;i++){
     A[i]=kbd.nextInt();
   }

   Arrays.sort(A);
   int x=0;
   for(int i=0;i<k;i++){
     x=x+A[i];
   }
   System.out.println(x);
 }
} public class Main{
 public static void main(String[] args) {
   Scanner kbd =new Scanner(System.in);
   int n =kbd.nextInt();
   int k =kbd.nextInt();
   int[] A= new int[n];
   for(int i=0;i<n;i++){
     A[i]=kbd.nextInt();
   }

   Arrays.sort(A);
   int x=0;
   for(int i=0;i<k;i++){
     x=x+A[i];
   }
   System.out.println(x);
 }
} Main
import java.util.Scanner;
import java.util.Arrays;
public class Main{
 public static void main(String[] args) {
   Scanner kbd =new Scanner(System.in);
   int n =kbd.nextInt();
   int k =kbd.nextInt();
   int[] A= new int[n];
   for(int i=0;i<n;i++){
     A[i]=kbd.nextInt();
   }

   Arrays.sort(A);
   int x=0;
   for(int i=0;i<k;i++){
     x=x+A[i];
   }
   System.out.println(x);
 }
}
