//package gfg;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

 class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
////		int t=Integer.parseInt(br.readLine().trim());
//		while(t-->0)
//		{
			String[] s1=br.readLine().split(" ");
			int n=Integer.parseInt(s1[0].trim());	
			int k=Integer.parseInt(s1[1].trim());	
			String[] s=br.readLine().split(" ");
			int[] a=new int[n];
			for(int i=0;i<n;i++)
			{
				a[i]=Integer.parseInt(s[i].trim());
			}
			
			System.out.println(algo(a,k));
		
//		}
	}

	public static int algo(int[] a,int k) {
		Arrays.sort(a);
		int sum=0;
		for(int i=0;i<k;i++) {
			sum+=a[i];
		}
		
		return sum;
		
	}
	
	
	
}
 import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.*; util.* java class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
////		int t=Integer.parseInt(br.readLine().trim());
//		while(t-->0)
//		{
			String[] s1=br.readLine().split(" ");
			int n=Integer.parseInt(s1[0].trim());	
			int k=Integer.parseInt(s1[1].trim());	
			String[] s=br.readLine().split(" ");
			int[] a=new int[n];
			for(int i=0;i<n;i++)
			{
				a[i]=Integer.parseInt(s[i].trim());
			}
			
			System.out.println(algo(a,k));
		
//		}
	}

	public static int algo(int[] a,int k) {
		Arrays.sort(a);
		int sum=0;
		for(int i=0;i<k;i++) {
			sum+=a[i];
		}
		
		return sum;
		
	}
	
	
	
} Main public static void main(String[] args) throws Exception {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
////		int t=Integer.parseInt(br.readLine().trim());
//		while(t-->0)
//		{
			String[] s1=br.readLine().split(" ");
			int n=Integer.parseInt(s1[0].trim());	
			int k=Integer.parseInt(s1[1].trim());	
			String[] s=br.readLine().split(" ");
			int[] a=new int[n];
			for(int i=0;i<n;i++)
			{
				a[i]=Integer.parseInt(s[i].trim());
			}
			
			System.out.println(algo(a,k));
		
//		}
	} main {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
////		int t=Integer.parseInt(br.readLine().trim());
//		while(t-->0)
//		{
			String[] s1=br.readLine().split(" ");
			int n=Integer.parseInt(s1[0].trim());	
			int k=Integer.parseInt(s1[1].trim());	
			String[] s=br.readLine().split(" ");
			int[] a=new int[n];
			for(int i=0;i<n;i++)
			{
				a[i]=Integer.parseInt(s[i].trim());
			}
			
			System.out.println(algo(a,k));
		
//		}
	} BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] s1=br.readLine().split(" "); s1 br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int n=Integer.parseInt(s1[0].trim()); n Integer.parseInt(s1[0].trim()) Integer.parseInt Integer s1[0].trim() s1[0].trim s1[0] s1 0 int k=Integer.parseInt(s1[1].trim()); k Integer.parseInt(s1[1].trim()) Integer.parseInt Integer s1[1].trim() s1[1].trim s1[1] s1 1 String[] s=br.readLine().split(" "); s br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int[] a=new int[n]; a new int[n] n for(int i=0;i<n;i++)
			{
				a[i]=Integer.parseInt(s[i].trim());
			} int i=0; int i=0; i 0 i<n i n i++ i++ i {
				a[i]=Integer.parseInt(s[i].trim());
			} {
				a[i]=Integer.parseInt(s[i].trim());
			} a[i]=Integer.parseInt(s[i].trim()) a[i] a i Integer.parseInt(s[i].trim()) Integer.parseInt Integer s[i].trim() s[i].trim s[i] s i System.out.println(algo(a,k)) System.out.println System.out System System.out algo(a,k) algo a k String[] args args public static int algo(int[] a,int k) {
		Arrays.sort(a);
		int sum=0;
		for(int i=0;i<k;i++) {
			sum+=a[i];
		}
		
		return sum;
		
	} algo {
		Arrays.sort(a);
		int sum=0;
		for(int i=0;i<k;i++) {
			sum+=a[i];
		}
		
		return sum;
		
	} Arrays.sort(a) Arrays.sort Arrays a int sum=0; sum 0 for(int i=0;i<k;i++) {
			sum+=a[i];
		} int i=0; int i=0; i 0 i<k i k i++ i++ i {
			sum+=a[i];
		} {
			sum+=a[i];
		} sum+=a[i] sum a[i] a i return sum; sum int[] a a int k k
//package gfg;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

 class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
////		int t=Integer.parseInt(br.readLine().trim());
//		while(t-->0)
//		{
			String[] s1=br.readLine().split(" ");
			int n=Integer.parseInt(s1[0].trim());	
			int k=Integer.parseInt(s1[1].trim());	
			String[] s=br.readLine().split(" ");
			int[] a=new int[n];
			for(int i=0;i<n;i++)
			{
				a[i]=Integer.parseInt(s[i].trim());
			}
			
			System.out.println(algo(a,k));
		
//		}
	}

	public static int algo(int[] a,int k) {
		Arrays.sort(a);
		int sum=0;
		for(int i=0;i<k;i++) {
			sum+=a[i];
		}
		
		return sum;
		
	}
	
	
	
}

