import java.util.*;

class Main{
	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];
      int sacrifice = 0;
      int sum = 0;
      
      for(int i=0;i<N;i++){
        p[i] = sc.nextInt();
      }
      
      for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
          if(p[i] > p[j]){
            sacrifice = p[i];
            p[i] = p[j];
            p[j] = sacrifice;
          }
        }
      }
      
      for(int i=0;i<K;i++){
        sum += p[i];
      }
      
      System.out.println(sum);
	}
} import java.util.*; util.* java class Main{
	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];
      int sacrifice = 0;
      int sum = 0;
      
      for(int i=0;i<N;i++){
        p[i] = sc.nextInt();
      }
      
      for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
          if(p[i] > p[j]){
            sacrifice = p[i];
            p[i] = p[j];
            p[j] = sacrifice;
          }
        }
      }
      
      for(int i=0;i<K;i++){
        sum += p[i];
      }
      
      System.out.println(sum);
	}
} Main 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];
      int sacrifice = 0;
      int sum = 0;
      
      for(int i=0;i<N;i++){
        p[i] = sc.nextInt();
      }
      
      for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
          if(p[i] > p[j]){
            sacrifice = p[i];
            p[i] = p[j];
            p[j] = sacrifice;
          }
        }
      }
      
      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];
      int sacrifice = 0;
      int sum = 0;
      
      for(int i=0;i<N;i++){
        p[i] = sc.nextInt();
      }
      
      for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
          if(p[i] > p[j]){
            sacrifice = p[i];
            p[i] = p[j];
            p[j] = sacrifice;
          }
        }
      }
      
      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 int sacrifice = 0; sacrifice 0 int sum = 0; sum 0 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 for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
          if(p[i] > p[j]){
            sacrifice = p[i];
            p[i] = p[j];
            p[j] = sacrifice;
          }
        }
      } int i=0; int i=0; i 0 i<N i N i++ i++ i {
        for(int j=i+1;j<N;j++){
          if(p[i] > p[j]){
            sacrifice = p[i];
            p[i] = p[j];
            p[j] = sacrifice;
          }
        }
      } {
        for(int j=i+1;j<N;j++){
          if(p[i] > p[j]){
            sacrifice = p[i];
            p[i] = p[j];
            p[j] = sacrifice;
          }
        }
      } for(int j=i+1;j<N;j++){
          if(p[i] > p[j]){
            sacrifice = p[i];
            p[i] = p[j];
            p[j] = sacrifice;
          }
        } int j=i+1; int j=i+1; j i+1 i 1 j<N j N j++ j++ j {
          if(p[i] > p[j]){
            sacrifice = p[i];
            p[i] = p[j];
            p[j] = sacrifice;
          }
        } {
          if(p[i] > p[j]){
            sacrifice = p[i];
            p[i] = p[j];
            p[j] = sacrifice;
          }
        } if(p[i] > p[j]){
            sacrifice = p[i];
            p[i] = p[j];
            p[j] = sacrifice;
          } p[i] > p[j] p[i] p i p[j] p j {
            sacrifice = p[i];
            p[i] = p[j];
            p[j] = sacrifice;
          } sacrifice = p[i] sacrifice p[i] p i p[i] = p[j] p[i] p i p[j] p j p[j] = sacrifice p[j] p j sacrifice 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.*;

class Main{
	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];
      int sacrifice = 0;
      int sum = 0;
      
      for(int i=0;i<N;i++){
        p[i] = sc.nextInt();
      }
      
      for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
          if(p[i] > p[j]){
            sacrifice = p[i];
            p[i] = p[j];
            p[j] = sacrifice;
          }
        }
      }
      
      for(int i=0;i<K;i++){
        sum += p[i];
      }
      
      System.out.println(sum);
	}
}