import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer; 
import java.util.*;
  
public class Main
{ 
    //By shwetank_verma
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
    static int mod=1000000007;
    static boolean primes[]=new boolean[1000007];
    
    static boolean seive(int n){
        Arrays.fill(primes,true);
        primes[0]=primes[1]=false;
        for(int i=2;i*i<=n;i++){
            if(primes[i]==true){
                for(int p=i*i;p<=n;p+=i){
                    primes[p]=false;
                }
            }
        }
        if(n<1000007){
            return primes[n];
        }
        return false;
        
    }
    static int gcd(int a,int b){
        if(b==0)
        return a;
        return gcd(b,a%b);
    }
    static long GCD(long a,long b){
        if(b==0)
        return a;
        return GCD(b,a%b);
    }
    
  
    public static void main(String[] args) 
    { 
        FastReader sc=new FastReader(); 
        try{
           
                
                int n=sc.nextInt();
                int k=sc.nextInt();
                
                int a[]=new int[n];
                for(int i=0;i<n;i++){
                    a[i]=sc.nextInt();
                }
                Arrays.sort(a);
                int s=0;
                for(int i=0;i<k;i++)
                {
                	s+=a[i];
                }
                System.out.println(s);
                
           
            
        }catch(Exception e){
            return;
        }
    } 
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.Scanner; Scanner java.util import java.util.StringTokenizer; StringTokenizer java.util import java.util.*; util.* java public class Main
{ 
    //By shwetank_verma
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
    static int mod=1000000007;
    static boolean primes[]=new boolean[1000007];
    
    static boolean seive(int n){
        Arrays.fill(primes,true);
        primes[0]=primes[1]=false;
        for(int i=2;i*i<=n;i++){
            if(primes[i]==true){
                for(int p=i*i;p<=n;p+=i){
                    primes[p]=false;
                }
            }
        }
        if(n<1000007){
            return primes[n];
        }
        return false;
        
    }
    static int gcd(int a,int b){
        if(b==0)
        return a;
        return gcd(b,a%b);
    }
    static long GCD(long a,long b){
        if(b==0)
        return a;
        return GCD(b,a%b);
    }
    
  
    public static void main(String[] args) 
    { 
        FastReader sc=new FastReader(); 
        try{
           
                
                int n=sc.nextInt();
                int k=sc.nextInt();
                
                int a[]=new int[n];
                for(int i=0;i<n;i++){
                    a[i]=sc.nextInt();
                }
                Arrays.sort(a);
                int s=0;
                for(int i=0;i<k;i++)
                {
                	s+=a[i];
                }
                System.out.println(s);
                
           
            
        }catch(Exception e){
            return;
        }
    } 
} Main static int mod=1000000007; mod 1000000007 static boolean primes[]=new boolean[1000007]; primes new boolean[1000007] 1000007 static boolean seive(int n){
        Arrays.fill(primes,true);
        primes[0]=primes[1]=false;
        for(int i=2;i*i<=n;i++){
            if(primes[i]==true){
                for(int p=i*i;p<=n;p+=i){
                    primes[p]=false;
                }
            }
        }
        if(n<1000007){
            return primes[n];
        }
        return false;
        
    } seive {
        Arrays.fill(primes,true);
        primes[0]=primes[1]=false;
        for(int i=2;i*i<=n;i++){
            if(primes[i]==true){
                for(int p=i*i;p<=n;p+=i){
                    primes[p]=false;
                }
            }
        }
        if(n<1000007){
            return primes[n];
        }
        return false;
        
    } Arrays.fill(primes,true) Arrays.fill Arrays primes true primes[0]=primes[1]=false primes[0] primes 0 primes[1]=false primes[1] primes 1 false for(int i=2;i*i<=n;i++){
            if(primes[i]==true){
                for(int p=i*i;p<=n;p+=i){
                    primes[p]=false;
                }
            }
        } int i=2; int i=2; i 2 i*i<=n i*i i i n i++ i++ i {
            if(primes[i]==true){
                for(int p=i*i;p<=n;p+=i){
                    primes[p]=false;
                }
            }
        } {
            if(primes[i]==true){
                for(int p=i*i;p<=n;p+=i){
                    primes[p]=false;
                }
            }
        } if(primes[i]==true){
                for(int p=i*i;p<=n;p+=i){
                    primes[p]=false;
                }
            } primes[i]==true primes[i] primes i true {
                for(int p=i*i;p<=n;p+=i){
                    primes[p]=false;
                }
            } for(int p=i*i;p<=n;p+=i){
                    primes[p]=false;
                } int p=i*i; int p=i*i; p i*i i i p<=n p n p+=i p+=i p i {
                    primes[p]=false;
                } {
                    primes[p]=false;
                } primes[p]=false primes[p] primes p false if(n<1000007){
            return primes[n];
        } n<1000007 n 1000007 {
            return primes[n];
        } return primes[n]; primes[n] primes n return false; false int n n static int gcd(int a,int b){
        if(b==0)
        return a;
        return gcd(b,a%b);
    } gcd {
        if(b==0)
        return a;
        return gcd(b,a%b);
    } if(b==0)
        return a; b==0 b 0 return a; a return gcd(b,a%b); gcd(b,a%b) gcd b a%b a b int a a int b b static long GCD(long a,long b){
        if(b==0)
        return a;
        return GCD(b,a%b);
    } GCD {
        if(b==0)
        return a;
        return GCD(b,a%b);
    } if(b==0)
        return a; b==0 b 0 return a; a return GCD(b,a%b); GCD(b,a%b) GCD b a%b a b long a a long b b public static void main(String[] args) 
    { 
        FastReader sc=new FastReader(); 
        try{
           
                
                int n=sc.nextInt();
                int k=sc.nextInt();
                
                int a[]=new int[n];
                for(int i=0;i<n;i++){
                    a[i]=sc.nextInt();
                }
                Arrays.sort(a);
                int s=0;
                for(int i=0;i<k;i++)
                {
                	s+=a[i];
                }
                System.out.println(s);
                
           
            
        }catch(Exception e){
            return;
        }
    } main { 
        FastReader sc=new FastReader(); 
        try{
           
                
                int n=sc.nextInt();
                int k=sc.nextInt();
                
                int a[]=new int[n];
                for(int i=0;i<n;i++){
                    a[i]=sc.nextInt();
                }
                Arrays.sort(a);
                int s=0;
                for(int i=0;i<k;i++)
                {
                	s+=a[i];
                }
                System.out.println(s);
                
           
            
        }catch(Exception e){
            return;
        }
    } FastReader sc=new FastReader(); sc new FastReader() try{
           
                
                int n=sc.nextInt();
                int k=sc.nextInt();
                
                int a[]=new int[n];
                for(int i=0;i<n;i++){
                    a[i]=sc.nextInt();
                }
                Arrays.sort(a);
                int s=0;
                for(int i=0;i<k;i++)
                {
                	s+=a[i];
                }
                System.out.println(s);
                
           
            
        }catch(Exception e){
            return;
        } catch(Exception e){
            return;
        } Exception e {
            return;
        } return; {
           
                
                int n=sc.nextInt();
                int k=sc.nextInt();
                
                int a[]=new int[n];
                for(int i=0;i<n;i++){
                    a[i]=sc.nextInt();
                }
                Arrays.sort(a);
                int s=0;
                for(int i=0;i<k;i++)
                {
                	s+=a[i];
                }
                System.out.println(s);
                
           
            
        } int n=sc.nextInt(); n sc.nextInt() sc.nextInt sc int k=sc.nextInt(); k sc.nextInt() sc.nextInt sc int a[]=new int[n]; a new int[n] n for(int i=0;i<n;i++){
                    a[i]=sc.nextInt();
                } int i=0; int i=0; i 0 i<n i n i++ i++ i {
                    a[i]=sc.nextInt();
                } {
                    a[i]=sc.nextInt();
                } a[i]=sc.nextInt() a[i] a i sc.nextInt() sc.nextInt sc Arrays.sort(a) Arrays.sort Arrays a int s=0; s 0 for(int i=0;i<k;i++)
                {
                	s+=a[i];
                } int i=0; int i=0; i 0 i<k i k i++ i++ i {
                	s+=a[i];
                } {
                	s+=a[i];
                } s+=a[i] s a[i] a i System.out.println(s) System.out.println System.out System System.out s String[] args args static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } FastReader BufferedReader br; br StringTokenizer st; st public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } FastReader { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } br = new BufferedReader(new
                     InputStreamReader(System.in)) br new BufferedReader(new
                     InputStreamReader(System.in)) String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } next { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } st == null || !st.hasMoreElements() st == null st null !st.hasMoreElements() st.hasMoreElements() st.hasMoreElements st { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } IOException  e { 
                    e.printStackTrace(); 
                } e.printStackTrace() e.printStackTrace e { 
                    st = new StringTokenizer(br.readLine()); 
                } st = new StringTokenizer(br.readLine()) st new StringTokenizer(br.readLine()) return st.nextToken(); st.nextToken() st.nextToken st int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } nextInt { 
            return Integer.parseInt(next()); 
        } return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next long nextLong() 
        { 
            return Long.parseLong(next()); 
        } nextLong { 
            return Long.parseLong(next()); 
        } return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } nextDouble { 
            return Double.parseDouble(next()); 
        } return Double.parseDouble(next()); Double.parseDouble(next()) Double.parseDouble Double next() next String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } nextLine { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } String str = ""; str "" try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } catch (IOException e) 
            { 
                e.printStackTrace(); 
            } IOException e { 
                e.printStackTrace(); 
            } e.printStackTrace() e.printStackTrace e { 
                str = br.readLine(); 
            } str = br.readLine() str br.readLine() br.readLine br return str; str public class Main
{ 
    //By shwetank_verma
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
    static int mod=1000000007;
    static boolean primes[]=new boolean[1000007];
    
    static boolean seive(int n){
        Arrays.fill(primes,true);
        primes[0]=primes[1]=false;
        for(int i=2;i*i<=n;i++){
            if(primes[i]==true){
                for(int p=i*i;p<=n;p+=i){
                    primes[p]=false;
                }
            }
        }
        if(n<1000007){
            return primes[n];
        }
        return false;
        
    }
    static int gcd(int a,int b){
        if(b==0)
        return a;
        return gcd(b,a%b);
    }
    static long GCD(long a,long b){
        if(b==0)
        return a;
        return GCD(b,a%b);
    }
    
  
    public static void main(String[] args) 
    { 
        FastReader sc=new FastReader(); 
        try{
           
                
                int n=sc.nextInt();
                int k=sc.nextInt();
                
                int a[]=new int[n];
                for(int i=0;i<n;i++){
                    a[i]=sc.nextInt();
                }
                Arrays.sort(a);
                int s=0;
                for(int i=0;i<k;i++)
                {
                	s+=a[i];
                }
                System.out.println(s);
                
           
            
        }catch(Exception e){
            return;
        }
    } 
} public class Main
{ 
    //By shwetank_verma
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
    static int mod=1000000007;
    static boolean primes[]=new boolean[1000007];
    
    static boolean seive(int n){
        Arrays.fill(primes,true);
        primes[0]=primes[1]=false;
        for(int i=2;i*i<=n;i++){
            if(primes[i]==true){
                for(int p=i*i;p<=n;p+=i){
                    primes[p]=false;
                }
            }
        }
        if(n<1000007){
            return primes[n];
        }
        return false;
        
    }
    static int gcd(int a,int b){
        if(b==0)
        return a;
        return gcd(b,a%b);
    }
    static long GCD(long a,long b){
        if(b==0)
        return a;
        return GCD(b,a%b);
    }
    
  
    public static void main(String[] args) 
    { 
        FastReader sc=new FastReader(); 
        try{
           
                
                int n=sc.nextInt();
                int k=sc.nextInt();
                
                int a[]=new int[n];
                for(int i=0;i<n;i++){
                    a[i]=sc.nextInt();
                }
                Arrays.sort(a);
                int s=0;
                for(int i=0;i<k;i++)
                {
                	s+=a[i];
                }
                System.out.println(s);
                
           
            
        }catch(Exception e){
            return;
        }
    } 
} Main
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer; 
import java.util.*;
  
public class Main
{ 
    //By shwetank_verma
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
    static int mod=1000000007;
    static boolean primes[]=new boolean[1000007];
    
    static boolean seive(int n){
        Arrays.fill(primes,true);
        primes[0]=primes[1]=false;
        for(int i=2;i*i<=n;i++){
            if(primes[i]==true){
                for(int p=i*i;p<=n;p+=i){
                    primes[p]=false;
                }
            }
        }
        if(n<1000007){
            return primes[n];
        }
        return false;
        
    }
    static int gcd(int a,int b){
        if(b==0)
        return a;
        return gcd(b,a%b);
    }
    static long GCD(long a,long b){
        if(b==0)
        return a;
        return GCD(b,a%b);
    }
    
  
    public static void main(String[] args) 
    { 
        FastReader sc=new FastReader(); 
        try{
           
                
                int n=sc.nextInt();
                int k=sc.nextInt();
                
                int a[]=new int[n];
                for(int i=0;i<n;i++){
                    a[i]=sc.nextInt();
                }
                Arrays.sort(a);
                int s=0;
                for(int i=0;i<k;i++)
                {
                	s+=a[i];
                }
                System.out.println(s);
                
           
            
        }catch(Exception e){
            return;
        }
    } 
}
