//package atcoder;
 
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.*;
//import java.math.BigDecimal;
 
public class Main {
	public static void main(String [] args) {
	    int K,N;
	    
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		K = sc.nextInt();
		int p[] = new int [N];
		for(int i=0;i<N;i++) {
			p[i] = sc.nextInt();
		}
		Arrays.sort(p);
		/*for(int k=0;k<N;k++) {
			System.out.println(p[k]);
		}*/
		int goukei = 0;
		for(int j=0;j<K;j++) {
			goukei = goukei+p[j];
		}
		System.out.println(goukei);
		
	}
} import java.io.BufferedWriter; BufferedWriter java.io import java.io.File; File java.io import java.io.FileWriter; FileWriter java.io import java.io.IOException; IOException java.io import java.io.PrintWriter; PrintWriter java.io import java.util.*; util.* java public class Main {
	public static void main(String [] args) {
	    int K,N;
	    
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		K = sc.nextInt();
		int p[] = new int [N];
		for(int i=0;i<N;i++) {
			p[i] = sc.nextInt();
		}
		Arrays.sort(p);
		/*for(int k=0;k<N;k++) {
			System.out.println(p[k]);
		}*/
		int goukei = 0;
		for(int j=0;j<K;j++) {
			goukei = goukei+p[j];
		}
		System.out.println(goukei);
		
	}
} Main public static void main(String [] args) {
	    int K,N;
	    
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		K = sc.nextInt();
		int p[] = new int [N];
		for(int i=0;i<N;i++) {
			p[i] = sc.nextInt();
		}
		Arrays.sort(p);
		/*for(int k=0;k<N;k++) {
			System.out.println(p[k]);
		}*/
		int goukei = 0;
		for(int j=0;j<K;j++) {
			goukei = goukei+p[j];
		}
		System.out.println(goukei);
		
	} main {
	    int K,N;
	    
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		K = sc.nextInt();
		int p[] = new int [N];
		for(int i=0;i<N;i++) {
			p[i] = sc.nextInt();
		}
		Arrays.sort(p);
		/*for(int k=0;k<N;k++) {
			System.out.println(p[k]);
		}*/
		int goukei = 0;
		for(int j=0;j<K;j++) {
			goukei = goukei+p[j];
		}
		System.out.println(goukei);
		
	} int K K N; N Scanner sc = new Scanner(System.in); sc new Scanner(System.in) N = sc.nextInt() N sc.nextInt() sc.nextInt sc 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 Arrays.sort(p) Arrays.sort Arrays p int goukei = 0; goukei 0 for(int j=0;j<K;j++) {
			goukei = goukei+p[j];
		} int j=0; int j=0; j 0 j<K j K j++ j++ j {
			goukei = goukei+p[j];
		} {
			goukei = goukei+p[j];
		} goukei = goukei+p[j] goukei goukei+p[j] goukei p[j] p j System.out.println(goukei) System.out.println System.out System System.out goukei String [] args args public class Main {
	public static void main(String [] args) {
	    int K,N;
	    
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		K = sc.nextInt();
		int p[] = new int [N];
		for(int i=0;i<N;i++) {
			p[i] = sc.nextInt();
		}
		Arrays.sort(p);
		/*for(int k=0;k<N;k++) {
			System.out.println(p[k]);
		}*/
		int goukei = 0;
		for(int j=0;j<K;j++) {
			goukei = goukei+p[j];
		}
		System.out.println(goukei);
		
	}
} public class Main {
	public static void main(String [] args) {
	    int K,N;
	    
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		K = sc.nextInt();
		int p[] = new int [N];
		for(int i=0;i<N;i++) {
			p[i] = sc.nextInt();
		}
		Arrays.sort(p);
		/*for(int k=0;k<N;k++) {
			System.out.println(p[k]);
		}*/
		int goukei = 0;
		for(int j=0;j<K;j++) {
			goukei = goukei+p[j];
		}
		System.out.println(goukei);
		
	}
} Main
//package atcoder;
 
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.*;
//import java.math.BigDecimal;
 
public class Main {
	public static void main(String [] args) {
	    int K,N;
	    
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		K = sc.nextInt();
		int p[] = new int [N];
		for(int i=0;i<N;i++) {
			p[i] = sc.nextInt();
		}
		Arrays.sort(p);
		/*for(int k=0;k<N;k++) {
			System.out.println(p[k]);
		}*/
		int goukei = 0;
		for(int j=0;j<K;j++) {
			goukei = goukei+p[j];
		}
		System.out.println(goukei);
		
	}
}