import java.util.Scanner;
 
class Main{
  public static void main(String[] args){
    
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int K = scan.nextInt();
    int [] p = new int[N];
    for(int i = 0; i < N; i++){
      p[i] = scan.nextInt();
    }
    int k;
    for(int j = 0; j < N-1; j++){
      for(int l = j+1; l < N; l++){
        if(p[j] > p[l]){
          k = p[j];
          p[j] = p[l];
          p[l] = k;
        }
      }
    }
    
    int sum = 0;
    for(int m = 0; m < K; m++){
      sum += p[m];
    }
    
    System.out.println(sum);
    
    scan.close();
  }
}        import java.util.Scanner; Scanner java.util class Main{
  public static void main(String[] args){
    
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int K = scan.nextInt();
    int [] p = new int[N];
    for(int i = 0; i < N; i++){
      p[i] = scan.nextInt();
    }
    int k;
    for(int j = 0; j < N-1; j++){
      for(int l = j+1; l < N; l++){
        if(p[j] > p[l]){
          k = p[j];
          p[j] = p[l];
          p[l] = k;
        }
      }
    }
    
    int sum = 0;
    for(int m = 0; m < K; m++){
      sum += p[m];
    }
    
    System.out.println(sum);
    
    scan.close();
  }
} Main public static void main(String[] args){
    
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int K = scan.nextInt();
    int [] p = new int[N];
    for(int i = 0; i < N; i++){
      p[i] = scan.nextInt();
    }
    int k;
    for(int j = 0; j < N-1; j++){
      for(int l = j+1; l < N; l++){
        if(p[j] > p[l]){
          k = p[j];
          p[j] = p[l];
          p[l] = k;
        }
      }
    }
    
    int sum = 0;
    for(int m = 0; m < K; m++){
      sum += p[m];
    }
    
    System.out.println(sum);
    
    scan.close();
  } main {
    
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int K = scan.nextInt();
    int [] p = new int[N];
    for(int i = 0; i < N; i++){
      p[i] = scan.nextInt();
    }
    int k;
    for(int j = 0; j < N-1; j++){
      for(int l = j+1; l < N; l++){
        if(p[j] > p[l]){
          k = p[j];
          p[j] = p[l];
          p[l] = k;
        }
      }
    }
    
    int sum = 0;
    for(int m = 0; m < K; m++){
      sum += p[m];
    }
    
    System.out.println(sum);
    
    scan.close();
  } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int N = scan.nextInt(); N scan.nextInt() scan.nextInt scan int K = scan.nextInt(); K scan.nextInt() scan.nextInt scan int [] p = new int[N]; p new int[N] N for(int i = 0; i < N; i++){
      p[i] = scan.nextInt();
    } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
      p[i] = scan.nextInt();
    } {
      p[i] = scan.nextInt();
    } p[i] = scan.nextInt() p[i] p i scan.nextInt() scan.nextInt scan int k; k for(int j = 0; j < N-1; j++){
      for(int l = j+1; l < N; l++){
        if(p[j] > p[l]){
          k = p[j];
          p[j] = p[l];
          p[l] = k;
        }
      }
    } int j = 0; int j = 0; j 0 j < N-1 j N-1 N 1 j++ j++ j {
      for(int l = j+1; l < N; l++){
        if(p[j] > p[l]){
          k = p[j];
          p[j] = p[l];
          p[l] = k;
        }
      }
    } {
      for(int l = j+1; l < N; l++){
        if(p[j] > p[l]){
          k = p[j];
          p[j] = p[l];
          p[l] = k;
        }
      }
    } for(int l = j+1; l < N; l++){
        if(p[j] > p[l]){
          k = p[j];
          p[j] = p[l];
          p[l] = k;
        }
      } int l = j+1; int l = j+1; l j+1 j 1 l < N l N l++ l++ l {
        if(p[j] > p[l]){
          k = p[j];
          p[j] = p[l];
          p[l] = k;
        }
      } {
        if(p[j] > p[l]){
          k = p[j];
          p[j] = p[l];
          p[l] = k;
        }
      } if(p[j] > p[l]){
          k = p[j];
          p[j] = p[l];
          p[l] = k;
        } p[j] > p[l] p[j] p j p[l] p l {
          k = p[j];
          p[j] = p[l];
          p[l] = k;
        } k = p[j] k p[j] p j p[j] = p[l] p[j] p j p[l] p l p[l] = k p[l] p l k int sum = 0; sum 0 for(int m = 0; m < K; m++){
      sum += p[m];
    } int m = 0; int m = 0; m 0 m < K m K m++ m++ m {
      sum += p[m];
    } {
      sum += p[m];
    } sum += p[m] sum p[m] p m System.out.println(sum) System.out.println System.out System System.out sum scan.close() scan.close scan String[] args args
import java.util.Scanner;
 
class Main{
  public static void main(String[] args){
    
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int K = scan.nextInt();
    int [] p = new int[N];
    for(int i = 0; i < N; i++){
      p[i] = scan.nextInt();
    }
    int k;
    for(int j = 0; j < N-1; j++){
      for(int l = j+1; l < N; l++){
        if(p[j] > p[l]){
          k = p[j];
          p[j] = p[l];
          p[l] = k;
        }
      }
    }
    
    int sum = 0;
    for(int m = 0; m < K; m++){
      sum += p[m];
    }
    
    System.out.println(sum);
    
    scan.close();
  }
}       