import java.util.*;

public class Main {
 
	public static void main(String[] args) {
      Scanner sr = new Scanner(System.in);
      int N = sr.nextInt();
      int K = sr.nextInt();
      int p[] = new int[N];
      for(int i = 0;i<N;i++)
        p[i] = sr.nextInt();
      Arrays.sort(p);
      int sum = 0;
      for(int j = 0;j<K;j++)
        sum+=p[j];
      System.out.print(sum);
      
	}
} import java.util.*; util.* java public class Main {
 
	public static void main(String[] args) {
      Scanner sr = new Scanner(System.in);
      int N = sr.nextInt();
      int K = sr.nextInt();
      int p[] = new int[N];
      for(int i = 0;i<N;i++)
        p[i] = sr.nextInt();
      Arrays.sort(p);
      int sum = 0;
      for(int j = 0;j<K;j++)
        sum+=p[j];
      System.out.print(sum);
      
	}
} Main public static void main(String[] args) {
      Scanner sr = new Scanner(System.in);
      int N = sr.nextInt();
      int K = sr.nextInt();
      int p[] = new int[N];
      for(int i = 0;i<N;i++)
        p[i] = sr.nextInt();
      Arrays.sort(p);
      int sum = 0;
      for(int j = 0;j<K;j++)
        sum+=p[j];
      System.out.print(sum);
      
	} main {
      Scanner sr = new Scanner(System.in);
      int N = sr.nextInt();
      int K = sr.nextInt();
      int p[] = new int[N];
      for(int i = 0;i<N;i++)
        p[i] = sr.nextInt();
      Arrays.sort(p);
      int sum = 0;
      for(int j = 0;j<K;j++)
        sum+=p[j];
      System.out.print(sum);
      
	} Scanner sr = new Scanner(System.in); sr new Scanner(System.in) int N = sr.nextInt(); N sr.nextInt() sr.nextInt sr int K = sr.nextInt(); K sr.nextInt() sr.nextInt sr int p[] = new int[N]; p new int[N] N for(int i = 0;i<N;i++)
        p[i] = sr.nextInt(); int i = 0; int i = 0; i 0 i<N i N i++ i++ i p[i] = sr.nextInt(); p[i] = sr.nextInt() p[i] p i sr.nextInt() sr.nextInt sr Arrays.sort(p) Arrays.sort Arrays p int sum = 0; sum 0 for(int j = 0;j<K;j++)
        sum+=p[j]; int j = 0; int j = 0; j 0 j<K j K j++ j++ j sum+=p[j]; sum+=p[j] sum p[j] p j System.out.print(sum) System.out.print System.out System System.out sum String[] args args public class Main {
 
	public static void main(String[] args) {
      Scanner sr = new Scanner(System.in);
      int N = sr.nextInt();
      int K = sr.nextInt();
      int p[] = new int[N];
      for(int i = 0;i<N;i++)
        p[i] = sr.nextInt();
      Arrays.sort(p);
      int sum = 0;
      for(int j = 0;j<K;j++)
        sum+=p[j];
      System.out.print(sum);
      
	}
} public class Main {
 
	public static void main(String[] args) {
      Scanner sr = new Scanner(System.in);
      int N = sr.nextInt();
      int K = sr.nextInt();
      int p[] = new int[N];
      for(int i = 0;i<N;i++)
        p[i] = sr.nextInt();
      Arrays.sort(p);
      int sum = 0;
      for(int j = 0;j<K;j++)
        sum+=p[j];
      System.out.print(sum);
      
	}
} Main
import java.util.*;

public class Main {
 
	public static void main(String[] args) {
      Scanner sr = new Scanner(System.in);
      int N = sr.nextInt();
      int K = sr.nextInt();
      int p[] = new int[N];
      for(int i = 0;i<N;i++)
        p[i] = sr.nextInt();
      Arrays.sort(p);
      int sum = 0;
      for(int j = 0;j<K;j++)
        sum+=p[j];
      System.out.print(sum);
      
	}
}