import java.util.*;

class Main{

  public static void main(String args[]){

    Scanner s=new Scanner(System.in);
    int N=s.nextInt();
    int K=s.nextInt();
    int[] L=new int[N];
	for(int i=0;i<N;i++) L[i]=s.nextInt();
    Arrays.sort(L);
    int ans=0;
    for(int i=0;i<K;i++) ans+=L[i];
    System.out.println(ans);

  }  
} import java.util.*; util.* java class Main{

  public static void main(String args[]){

    Scanner s=new Scanner(System.in);
    int N=s.nextInt();
    int K=s.nextInt();
    int[] L=new int[N];
	for(int i=0;i<N;i++) L[i]=s.nextInt();
    Arrays.sort(L);
    int ans=0;
    for(int i=0;i<K;i++) ans+=L[i];
    System.out.println(ans);

  }  
} Main public static void main(String args[]){

    Scanner s=new Scanner(System.in);
    int N=s.nextInt();
    int K=s.nextInt();
    int[] L=new int[N];
	for(int i=0;i<N;i++) L[i]=s.nextInt();
    Arrays.sort(L);
    int ans=0;
    for(int i=0;i<K;i++) ans+=L[i];
    System.out.println(ans);

  } main {

    Scanner s=new Scanner(System.in);
    int N=s.nextInt();
    int K=s.nextInt();
    int[] L=new int[N];
	for(int i=0;i<N;i++) L[i]=s.nextInt();
    Arrays.sort(L);
    int ans=0;
    for(int i=0;i<K;i++) ans+=L[i];
    System.out.println(ans);

  } Scanner s=new Scanner(System.in); s new Scanner(System.in) int N=s.nextInt(); N s.nextInt() s.nextInt s int K=s.nextInt(); K s.nextInt() s.nextInt s int[] L=new int[N]; L new int[N] N for(int i=0;i<N;i++) L[i]=s.nextInt(); int i=0; int i=0; i 0 i<N i N i++ i++ i L[i]=s.nextInt(); L[i]=s.nextInt() L[i] L i s.nextInt() s.nextInt s Arrays.sort(L) Arrays.sort Arrays L int ans=0; ans 0 for(int i=0;i<K;i++) ans+=L[i]; int i=0; int i=0; i 0 i<K i K i++ i++ i ans+=L[i]; ans+=L[i] ans L[i] L i System.out.println(ans) System.out.println System.out System System.out ans String args[] args
import java.util.*;

class Main{

  public static void main(String args[]){

    Scanner s=new Scanner(System.in);
    int N=s.nextInt();
    int K=s.nextInt();
    int[] L=new int[N];
	for(int i=0;i<N;i++) L[i]=s.nextInt();
    Arrays.sort(L);
    int ans=0;
    for(int i=0;i<K;i++) ans+=L[i];
    System.out.println(ans);

  }  
}