/*package whatever //do not write package name here */
import java.util.*;
import java.lang.*;
import java.io.*;

class Main {
	public static void main (String[] args) {
// 		System.out.println("GfG!");
        Scanner input=new Scanner(System.in);
       int n=input.nextInt();
       int k=input.nextInt();
       int[] p=new int[n];
       for(int i=0;i<n;i++)
            p[i]=input.nextInt();
        Arrays.sort(p);
        int ans=0;
        for(int i=0;i<k;i++)
            ans+=p[i];
        System.out.println(ans);
       input.close();
	}
} import java.util.*; util.* java import java.lang.*; lang.* java import java.io.*; io.* java class Main {
	public static void main (String[] args) {
// 		System.out.println("GfG!");
        Scanner input=new Scanner(System.in);
       int n=input.nextInt();
       int k=input.nextInt();
       int[] p=new int[n];
       for(int i=0;i<n;i++)
            p[i]=input.nextInt();
        Arrays.sort(p);
        int ans=0;
        for(int i=0;i<k;i++)
            ans+=p[i];
        System.out.println(ans);
       input.close();
	}
} Main public static void main (String[] args) {
// 		System.out.println("GfG!");
        Scanner input=new Scanner(System.in);
       int n=input.nextInt();
       int k=input.nextInt();
       int[] p=new int[n];
       for(int i=0;i<n;i++)
            p[i]=input.nextInt();
        Arrays.sort(p);
        int ans=0;
        for(int i=0;i<k;i++)
            ans+=p[i];
        System.out.println(ans);
       input.close();
	} main {
// 		System.out.println("GfG!");
        Scanner input=new Scanner(System.in);
       int n=input.nextInt();
       int k=input.nextInt();
       int[] p=new int[n];
       for(int i=0;i<n;i++)
            p[i]=input.nextInt();
        Arrays.sort(p);
        int ans=0;
        for(int i=0;i<k;i++)
            ans+=p[i];
        System.out.println(ans);
       input.close();
	} Scanner input=new Scanner(System.in); input new Scanner(System.in) int n=input.nextInt(); n input.nextInt() input.nextInt input int k=input.nextInt(); k input.nextInt() input.nextInt input int[] p=new int[n]; p new int[n] n for(int i=0;i<n;i++)
            p[i]=input.nextInt(); int i=0; int i=0; i 0 i<n i n i++ i++ i p[i]=input.nextInt(); p[i]=input.nextInt() p[i] p i input.nextInt() input.nextInt input Arrays.sort(p) Arrays.sort Arrays p int ans=0; ans 0 for(int i=0;i<k;i++)
            ans+=p[i]; int i=0; int i=0; i 0 i<k i k i++ i++ i ans+=p[i]; ans+=p[i] ans p[i] p i System.out.println(ans) System.out.println System.out System System.out ans input.close() input.close input String[] args args
/*package whatever //do not write package name here */
import java.util.*;
import java.lang.*;
import java.io.*;

class Main {
	public static void main (String[] args) {
// 		System.out.println("GfG!");
        Scanner input=new Scanner(System.in);
       int n=input.nextInt();
       int k=input.nextInt();
       int[] p=new int[n];
       for(int i=0;i<n;i++)
            p[i]=input.nextInt();
        Arrays.sort(p);
        int ans=0;
        for(int i=0;i<k;i++)
            ans+=p[i];
        System.out.println(ans);
       input.close();
	}
}