import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int many = scan.nextInt();
		int kind = scan.nextInt();
		int yen;
		int[] yenbox = new int[many];
		for(int i=0;i<many;i++) {
			yen = scan.nextInt();
			yenbox[i] = yen;
		}
		int min;
		for(int i=0;i<many;i++) {
			for(int j=i;j<many;j++) {
				if(yenbox[i]>yenbox[j]) {
					min = yenbox[i];
					yenbox[i] = yenbox[j];
					yenbox[j] = min;
				}
			}
		}
		int answer = 0;
		for(int i=0;i<kind;i++) {
			answer += yenbox[i];
		}
		System.out.print(answer);
	}

} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int many = scan.nextInt();
		int kind = scan.nextInt();
		int yen;
		int[] yenbox = new int[many];
		for(int i=0;i<many;i++) {
			yen = scan.nextInt();
			yenbox[i] = yen;
		}
		int min;
		for(int i=0;i<many;i++) {
			for(int j=i;j<many;j++) {
				if(yenbox[i]>yenbox[j]) {
					min = yenbox[i];
					yenbox[i] = yenbox[j];
					yenbox[j] = min;
				}
			}
		}
		int answer = 0;
		for(int i=0;i<kind;i++) {
			answer += yenbox[i];
		}
		System.out.print(answer);
	}

} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int many = scan.nextInt();
		int kind = scan.nextInt();
		int yen;
		int[] yenbox = new int[many];
		for(int i=0;i<many;i++) {
			yen = scan.nextInt();
			yenbox[i] = yen;
		}
		int min;
		for(int i=0;i<many;i++) {
			for(int j=i;j<many;j++) {
				if(yenbox[i]>yenbox[j]) {
					min = yenbox[i];
					yenbox[i] = yenbox[j];
					yenbox[j] = min;
				}
			}
		}
		int answer = 0;
		for(int i=0;i<kind;i++) {
			answer += yenbox[i];
		}
		System.out.print(answer);
	} main {
		Scanner scan = new Scanner(System.in);
		int many = scan.nextInt();
		int kind = scan.nextInt();
		int yen;
		int[] yenbox = new int[many];
		for(int i=0;i<many;i++) {
			yen = scan.nextInt();
			yenbox[i] = yen;
		}
		int min;
		for(int i=0;i<many;i++) {
			for(int j=i;j<many;j++) {
				if(yenbox[i]>yenbox[j]) {
					min = yenbox[i];
					yenbox[i] = yenbox[j];
					yenbox[j] = min;
				}
			}
		}
		int answer = 0;
		for(int i=0;i<kind;i++) {
			answer += yenbox[i];
		}
		System.out.print(answer);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int many = scan.nextInt(); many scan.nextInt() scan.nextInt scan int kind = scan.nextInt(); kind scan.nextInt() scan.nextInt scan int yen; yen int[] yenbox = new int[many]; yenbox new int[many] many for(int i=0;i<many;i++) {
			yen = scan.nextInt();
			yenbox[i] = yen;
		} int i=0; int i=0; i 0 i<many i many i++ i++ i {
			yen = scan.nextInt();
			yenbox[i] = yen;
		} {
			yen = scan.nextInt();
			yenbox[i] = yen;
		} yen = scan.nextInt() yen scan.nextInt() scan.nextInt scan yenbox[i] = yen yenbox[i] yenbox i yen int min; min for(int i=0;i<many;i++) {
			for(int j=i;j<many;j++) {
				if(yenbox[i]>yenbox[j]) {
					min = yenbox[i];
					yenbox[i] = yenbox[j];
					yenbox[j] = min;
				}
			}
		} int i=0; int i=0; i 0 i<many i many i++ i++ i {
			for(int j=i;j<many;j++) {
				if(yenbox[i]>yenbox[j]) {
					min = yenbox[i];
					yenbox[i] = yenbox[j];
					yenbox[j] = min;
				}
			}
		} {
			for(int j=i;j<many;j++) {
				if(yenbox[i]>yenbox[j]) {
					min = yenbox[i];
					yenbox[i] = yenbox[j];
					yenbox[j] = min;
				}
			}
		} for(int j=i;j<many;j++) {
				if(yenbox[i]>yenbox[j]) {
					min = yenbox[i];
					yenbox[i] = yenbox[j];
					yenbox[j] = min;
				}
			} int j=i; int j=i; j i j<many j many j++ j++ j {
				if(yenbox[i]>yenbox[j]) {
					min = yenbox[i];
					yenbox[i] = yenbox[j];
					yenbox[j] = min;
				}
			} {
				if(yenbox[i]>yenbox[j]) {
					min = yenbox[i];
					yenbox[i] = yenbox[j];
					yenbox[j] = min;
				}
			} if(yenbox[i]>yenbox[j]) {
					min = yenbox[i];
					yenbox[i] = yenbox[j];
					yenbox[j] = min;
				} yenbox[i]>yenbox[j] yenbox[i] yenbox i yenbox[j] yenbox j {
					min = yenbox[i];
					yenbox[i] = yenbox[j];
					yenbox[j] = min;
				} min = yenbox[i] min yenbox[i] yenbox i yenbox[i] = yenbox[j] yenbox[i] yenbox i yenbox[j] yenbox j yenbox[j] = min yenbox[j] yenbox j min int answer = 0; answer 0 for(int i=0;i<kind;i++) {
			answer += yenbox[i];
		} int i=0; int i=0; i 0 i<kind i kind i++ i++ i {
			answer += yenbox[i];
		} {
			answer += yenbox[i];
		} answer += yenbox[i] answer yenbox[i] yenbox i System.out.print(answer) System.out.print System.out System System.out answer String[] args args public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int many = scan.nextInt();
		int kind = scan.nextInt();
		int yen;
		int[] yenbox = new int[many];
		for(int i=0;i<many;i++) {
			yen = scan.nextInt();
			yenbox[i] = yen;
		}
		int min;
		for(int i=0;i<many;i++) {
			for(int j=i;j<many;j++) {
				if(yenbox[i]>yenbox[j]) {
					min = yenbox[i];
					yenbox[i] = yenbox[j];
					yenbox[j] = min;
				}
			}
		}
		int answer = 0;
		for(int i=0;i<kind;i++) {
			answer += yenbox[i];
		}
		System.out.print(answer);
	}

} public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int many = scan.nextInt();
		int kind = scan.nextInt();
		int yen;
		int[] yenbox = new int[many];
		for(int i=0;i<many;i++) {
			yen = scan.nextInt();
			yenbox[i] = yen;
		}
		int min;
		for(int i=0;i<many;i++) {
			for(int j=i;j<many;j++) {
				if(yenbox[i]>yenbox[j]) {
					min = yenbox[i];
					yenbox[i] = yenbox[j];
					yenbox[j] = min;
				}
			}
		}
		int answer = 0;
		for(int i=0;i<kind;i++) {
			answer += yenbox[i];
		}
		System.out.print(answer);
	}

} Main
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int many = scan.nextInt();
		int kind = scan.nextInt();
		int yen;
		int[] yenbox = new int[many];
		for(int i=0;i<many;i++) {
			yen = scan.nextInt();
			yenbox[i] = yen;
		}
		int min;
		for(int i=0;i<many;i++) {
			for(int j=i;j<many;j++) {
				if(yenbox[i]>yenbox[j]) {
					min = yenbox[i];
					yenbox[i] = yenbox[j];
					yenbox[j] = min;
				}
			}
		}
		int answer = 0;
		for(int i=0;i<kind;i++) {
			answer += yenbox[i];
		}
		System.out.print(answer);
	}

}