import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
class Main{
	public static void main(String[] args) {
		InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
      	int n=in.nextInt(), k=in.nextInt(),sum=0;
      	int a[]=new int[n];
      	for(int i=0;i<n;i++)
      		a[i]=in.nextInt();
      	Arrays.sort(a);
      	for(int i=0;i<k;i++){
      		sum+=a[i];
      	}
      	System.out.println(sum);
	} 
} import java.util.*; util.* java import java.lang.*; lang.* java import java.math.*; math.* java import java.io.*; io.* java class Main{
	public static void main(String[] args) {
		InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
      	int n=in.nextInt(), k=in.nextInt(),sum=0;
      	int a[]=new int[n];
      	for(int i=0;i<n;i++)
      		a[i]=in.nextInt();
      	Arrays.sort(a);
      	for(int i=0;i<k;i++){
      		sum+=a[i];
      	}
      	System.out.println(sum);
	} 
} Main public static void main(String[] args) {
		InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
      	int n=in.nextInt(), k=in.nextInt(),sum=0;
      	int a[]=new int[n];
      	for(int i=0;i<n;i++)
      		a[i]=in.nextInt();
      	Arrays.sort(a);
      	for(int i=0;i<k;i++){
      		sum+=a[i];
      	}
      	System.out.println(sum);
	} main {
		InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
      	int n=in.nextInt(), k=in.nextInt(),sum=0;
      	int a[]=new int[n];
      	for(int i=0;i<n;i++)
      		a[i]=in.nextInt();
      	Arrays.sort(a);
      	for(int i=0;i<k;i++){
      		sum+=a[i];
      	}
      	System.out.println(sum);
	} InputStream inputStream = System.in; inputStream System.in System System.in OutputStream outputStream = System.out; outputStream System.out System System.out Scanner in = new Scanner(inputStream); in new Scanner(inputStream) PrintWriter out = new PrintWriter(outputStream); out new PrintWriter(outputStream) int n=in.nextInt() n in.nextInt() in.nextInt in k=in.nextInt() k in.nextInt() in.nextInt in sum=0; sum 0 int a[]=new int[n]; a new int[n] n for(int i=0;i<n;i++)
      		a[i]=in.nextInt(); int i=0; int i=0; i 0 i<n i n i++ i++ i a[i]=in.nextInt(); a[i]=in.nextInt() a[i] a i in.nextInt() in.nextInt in Arrays.sort(a) Arrays.sort Arrays a for(int i=0;i<k;i++){
      		sum+=a[i];
      	} int i=0; int i=0; i 0 i<k i k i++ i++ i {
      		sum+=a[i];
      	} {
      		sum+=a[i];
      	} sum+=a[i] sum a[i] a i System.out.println(sum) System.out.println System.out System System.out sum String[] args args
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
class Main{
	public static void main(String[] args) {
		InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
      	int n=in.nextInt(), k=in.nextInt(),sum=0;
      	int a[]=new int[n];
      	for(int i=0;i<n;i++)
      		a[i]=in.nextInt();
      	Arrays.sort(a);
      	for(int i=0;i<k;i++){
      		sum+=a[i];
      	}
      	System.out.println(sum);
	} 
}
