import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

class Main{
  public static void main(String[] args) throws Exception{
	  Scanner sc = new Scanner(System.in);
	  int n = sc.nextInt();
	  int k = sc.nextInt();
	  ArrayList<Integer> a = new ArrayList<Integer>();
	  while(n-- > 0) {
		  a.add(sc.nextInt());
	  }
	  Collections.sort(a);
	  int ans = 0;
	  for(int i = 0; i < k; i++) {
		  ans += a.get(i);
	  }
	  System.out.println(ans);
  }
} import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util import java.util.Scanner; Scanner java.util class Main{
  public static void main(String[] args) throws Exception{
	  Scanner sc = new Scanner(System.in);
	  int n = sc.nextInt();
	  int k = sc.nextInt();
	  ArrayList<Integer> a = new ArrayList<Integer>();
	  while(n-- > 0) {
		  a.add(sc.nextInt());
	  }
	  Collections.sort(a);
	  int ans = 0;
	  for(int i = 0; i < k; i++) {
		  ans += a.get(i);
	  }
	  System.out.println(ans);
  }
} Main public static void main(String[] args) throws Exception{
	  Scanner sc = new Scanner(System.in);
	  int n = sc.nextInt();
	  int k = sc.nextInt();
	  ArrayList<Integer> a = new ArrayList<Integer>();
	  while(n-- > 0) {
		  a.add(sc.nextInt());
	  }
	  Collections.sort(a);
	  int ans = 0;
	  for(int i = 0; i < k; i++) {
		  ans += a.get(i);
	  }
	  System.out.println(ans);
  } main {
	  Scanner sc = new Scanner(System.in);
	  int n = sc.nextInt();
	  int k = sc.nextInt();
	  ArrayList<Integer> a = new ArrayList<Integer>();
	  while(n-- > 0) {
		  a.add(sc.nextInt());
	  }
	  Collections.sort(a);
	  int ans = 0;
	  for(int i = 0; i < k; i++) {
		  ans += a.get(i);
	  }
	  System.out.println(ans);
  } 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 ArrayList<Integer> a = new ArrayList<Integer>(); a new ArrayList<Integer>() while(n-- > 0) {
		  a.add(sc.nextInt());
	  } n-- > 0 n-- n 0 {
		  a.add(sc.nextInt());
	  } a.add(sc.nextInt()) a.add a sc.nextInt() sc.nextInt sc Collections.sort(a) Collections.sort Collections a int ans = 0; ans 0 for(int i = 0; i < k; i++) {
		  ans += a.get(i);
	  } int i = 0; int i = 0; i 0 i < k i k i++ i++ i {
		  ans += a.get(i);
	  } {
		  ans += a.get(i);
	  } ans += a.get(i) ans a.get(i) a.get a i System.out.println(ans) System.out.println System.out System System.out ans String[] args args
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

class Main{
  public static void main(String[] args) throws Exception{
	  Scanner sc = new Scanner(System.in);
	  int n = sc.nextInt();
	  int k = sc.nextInt();
	  ArrayList<Integer> a = new ArrayList<Integer>();
	  while(n-- > 0) {
		  a.add(sc.nextInt());
	  }
	  Collections.sort(a);
	  int ans = 0;
	  for(int i = 0; i < k; i++) {
		  ans += a.get(i);
	  }
	  System.out.println(ans);
  }
}