import java.util.Scanner;

class Main{
  static void swap(int[] a, int idx1, int idx2){
    int t = a[idx1]; a[idx1] = a[idx2]; a[idx2] = t;
  }

  static void quickSort(int[] a, int left, int right){
    int pl = left;
    int pr = right;
    int x  = a[(pl+pr)/2];

    do{
      while (a[pl] < x) pl++;
      while (a[pr] > x) pr--;
      if(pl <= pr)
         swap(a, pl++, pr--);
    }while(pl <= pr);

   if(left < pr) quickSort(a,left,pr);
   if(pl < right) quickSort(a,pl,right);
 }
  
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int[] p = new int[N];
    for(int i =0; i<N;i++){
      p[i] = sc.nextInt();
    }
    
    quickSort(p,0,N-1);
    
    int sum = 0;
    for(int i = 0; i<K; i++){
      sum += p[i];
    }
    System.out.println(sum);
  }
} import java.util.Scanner; Scanner java.util class Main{
  static void swap(int[] a, int idx1, int idx2){
    int t = a[idx1]; a[idx1] = a[idx2]; a[idx2] = t;
  }

  static void quickSort(int[] a, int left, int right){
    int pl = left;
    int pr = right;
    int x  = a[(pl+pr)/2];

    do{
      while (a[pl] < x) pl++;
      while (a[pr] > x) pr--;
      if(pl <= pr)
         swap(a, pl++, pr--);
    }while(pl <= pr);

   if(left < pr) quickSort(a,left,pr);
   if(pl < right) quickSort(a,pl,right);
 }
  
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int[] p = new int[N];
    for(int i =0; i<N;i++){
      p[i] = sc.nextInt();
    }
    
    quickSort(p,0,N-1);
    
    int sum = 0;
    for(int i = 0; i<K; i++){
      sum += p[i];
    }
    System.out.println(sum);
  }
} Main static void swap(int[] a, int idx1, int idx2){
    int t = a[idx1]; a[idx1] = a[idx2]; a[idx2] = t;
  } swap {
    int t = a[idx1]; a[idx1] = a[idx2]; a[idx2] = t;
  } int t = a[idx1]; t a[idx1] a idx1 a[idx1] = a[idx2] a[idx1] a idx1 a[idx2] a idx2 a[idx2] = t a[idx2] a idx2 t int[] a a int idx1 idx1 int idx2 idx2 static void quickSort(int[] a, int left, int right){
    int pl = left;
    int pr = right;
    int x  = a[(pl+pr)/2];

    do{
      while (a[pl] < x) pl++;
      while (a[pr] > x) pr--;
      if(pl <= pr)
         swap(a, pl++, pr--);
    }while(pl <= pr);

   if(left < pr) quickSort(a,left,pr);
   if(pl < right) quickSort(a,pl,right);
 } quickSort {
    int pl = left;
    int pr = right;
    int x  = a[(pl+pr)/2];

    do{
      while (a[pl] < x) pl++;
      while (a[pr] > x) pr--;
      if(pl <= pr)
         swap(a, pl++, pr--);
    }while(pl <= pr);

   if(left < pr) quickSort(a,left,pr);
   if(pl < right) quickSort(a,pl,right);
 } int pl = left; pl left int pr = right; pr right int x  = a[(pl+pr)/2]; x a[(pl+pr)/2] a (pl+pr)/2 (pl+pr) pl pr 2 do{
      while (a[pl] < x) pl++;
      while (a[pr] > x) pr--;
      if(pl <= pr)
         swap(a, pl++, pr--);
    }while(pl <= pr); pl <= pr pl pr {
      while (a[pl] < x) pl++;
      while (a[pr] > x) pr--;
      if(pl <= pr)
         swap(a, pl++, pr--);
    } while (a[pl] < x) pl++; a[pl] < x a[pl] a pl x pl++ pl while (a[pr] > x) pr--; a[pr] > x a[pr] a pr x pr-- pr if(pl <= pr)
         swap(a, pl++, pr--); pl <= pr pl pr swap(a, pl++, pr--) swap a pl++ pl pr-- pr if(left < pr) quickSort(a,left,pr); left < pr left pr quickSort(a,left,pr) quickSort a left pr if(pl < right) quickSort(a,pl,right); pl < right pl right quickSort(a,pl,right) quickSort a pl right int[] a a int left left int right right public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int[] p = new int[N];
    for(int i =0; i<N;i++){
      p[i] = sc.nextInt();
    }
    
    quickSort(p,0,N-1);
    
    int sum = 0;
    for(int i = 0; i<K; i++){
      sum += p[i];
    }
    System.out.println(sum);
  } main {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int[] p = new int[N];
    for(int i =0; i<N;i++){
      p[i] = sc.nextInt();
    }
    
    quickSort(p,0,N-1);
    
    int sum = 0;
    for(int i = 0; i<K; i++){
      sum += p[i];
    }
    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 int[] p = new int[N]; p new int[N] N for(int i =0; i<N;i++){
      p[i] = sc.nextInt();
    } int i =0; int i =0; i 0 i<N i N i++ i++ i {
      p[i] = sc.nextInt();
    } {
      p[i] = sc.nextInt();
    } p[i] = sc.nextInt() p[i] p i sc.nextInt() sc.nextInt sc quickSort(p,0,N-1) quickSort p 0 N-1 N 1 int sum = 0; sum 0 for(int i = 0; i<K; i++){
      sum += p[i];
    } int i = 0; int i = 0; i 0 i<K i K i++ i++ i {
      sum += p[i];
    } {
      sum += p[i];
    } sum += p[i] sum p[i] p i System.out.println(sum) System.out.println System.out System System.out sum String[] args args
import java.util.Scanner;

class Main{
  static void swap(int[] a, int idx1, int idx2){
    int t = a[idx1]; a[idx1] = a[idx2]; a[idx2] = t;
  }

  static void quickSort(int[] a, int left, int right){
    int pl = left;
    int pr = right;
    int x  = a[(pl+pr)/2];

    do{
      while (a[pl] < x) pl++;
      while (a[pr] > x) pr--;
      if(pl <= pr)
         swap(a, pl++, pr--);
    }while(pl <= pr);

   if(left < pr) quickSort(a,left,pr);
   if(pl < right) quickSort(a,pl,right);
 }
  
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int[] p = new int[N];
    for(int i =0; i<N;i++){
      p[i] = sc.nextInt();
    }
    
    quickSort(p,0,N-1);
    
    int sum = 0;
    for(int i = 0; i<K; i++){
      sum += p[i];
    }
    System.out.println(sum);
  }
}