import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] p = new int[n];
        for(int i = 1 ; i <= n ; i++ ){
            p[i - 1] = sc.nextInt(); 
        }
        for(int i = 1; i <= n ; i++ ){
            for(int j = 0 ; j < n - 1 ; j++ ){
                if(p[j] > p[j + 1]){
                    int ko = p[j];
                    p[j] = p[j + 1];
                    p[j + 1] = ko;
                }
            }
        }
        int s = 0;
        for(int i = 0 ; i < k ; i++ ){
            s = s + p[i];
        }
        System.out.println(s);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] p = new int[n];
        for(int i = 1 ; i <= n ; i++ ){
            p[i - 1] = sc.nextInt(); 
        }
        for(int i = 1; i <= n ; i++ ){
            for(int j = 0 ; j < n - 1 ; j++ ){
                if(p[j] > p[j + 1]){
                    int ko = p[j];
                    p[j] = p[j + 1];
                    p[j + 1] = ko;
                }
            }
        }
        int s = 0;
        for(int i = 0 ; i < k ; i++ ){
            s = s + p[i];
        }
        System.out.println(s);
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] p = new int[n];
        for(int i = 1 ; i <= n ; i++ ){
            p[i - 1] = sc.nextInt(); 
        }
        for(int i = 1; i <= n ; i++ ){
            for(int j = 0 ; j < n - 1 ; j++ ){
                if(p[j] > p[j + 1]){
                    int ko = p[j];
                    p[j] = p[j + 1];
                    p[j + 1] = ko;
                }
            }
        }
        int s = 0;
        for(int i = 0 ; i < k ; i++ ){
            s = s + p[i];
        }
        System.out.println(s);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] p = new int[n];
        for(int i = 1 ; i <= n ; i++ ){
            p[i - 1] = sc.nextInt(); 
        }
        for(int i = 1; i <= n ; i++ ){
            for(int j = 0 ; j < n - 1 ; j++ ){
                if(p[j] > p[j + 1]){
                    int ko = p[j];
                    p[j] = p[j + 1];
                    p[j + 1] = ko;
                }
            }
        }
        int s = 0;
        for(int i = 0 ; i < k ; i++ ){
            s = s + p[i];
        }
        System.out.println(s);
    } 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 int[] p = new int[n]; p new int[n] n for(int i = 1 ; i <= n ; i++ ){
            p[i - 1] = sc.nextInt(); 
        } int i = 1 ; int i = 1 ; i 1 i <= n i n i++ i++ i {
            p[i - 1] = sc.nextInt(); 
        } {
            p[i - 1] = sc.nextInt(); 
        } p[i - 1] = sc.nextInt() p[i - 1] p i - 1 i 1 sc.nextInt() sc.nextInt sc for(int i = 1; i <= n ; i++ ){
            for(int j = 0 ; j < n - 1 ; j++ ){
                if(p[j] > p[j + 1]){
                    int ko = p[j];
                    p[j] = p[j + 1];
                    p[j + 1] = ko;
                }
            }
        } int i = 1; int i = 1; i 1 i <= n i n i++ i++ i {
            for(int j = 0 ; j < n - 1 ; j++ ){
                if(p[j] > p[j + 1]){
                    int ko = p[j];
                    p[j] = p[j + 1];
                    p[j + 1] = ko;
                }
            }
        } {
            for(int j = 0 ; j < n - 1 ; j++ ){
                if(p[j] > p[j + 1]){
                    int ko = p[j];
                    p[j] = p[j + 1];
                    p[j + 1] = ko;
                }
            }
        } for(int j = 0 ; j < n - 1 ; j++ ){
                if(p[j] > p[j + 1]){
                    int ko = p[j];
                    p[j] = p[j + 1];
                    p[j + 1] = ko;
                }
            } int j = 0 ; int j = 0 ; j 0 j < n - 1 j n - 1 n 1 j++ j++ j {
                if(p[j] > p[j + 1]){
                    int ko = p[j];
                    p[j] = p[j + 1];
                    p[j + 1] = ko;
                }
            } {
                if(p[j] > p[j + 1]){
                    int ko = p[j];
                    p[j] = p[j + 1];
                    p[j + 1] = ko;
                }
            } if(p[j] > p[j + 1]){
                    int ko = p[j];
                    p[j] = p[j + 1];
                    p[j + 1] = ko;
                } p[j] > p[j + 1] p[j] p j p[j + 1] p j + 1 j 1 {
                    int ko = p[j];
                    p[j] = p[j + 1];
                    p[j + 1] = ko;
                } int ko = p[j]; ko p[j] p j p[j] = p[j + 1] p[j] p j p[j + 1] p j + 1 j 1 p[j + 1] = ko p[j + 1] p j + 1 j 1 ko int s = 0; s 0 for(int i = 0 ; i < k ; i++ ){
            s = s + p[i];
        } int i = 0 ; int i = 0 ; i 0 i < k i k i++ i++ i {
            s = s + p[i];
        } {
            s = s + p[i];
        } s = s + p[i] s s + p[i] s p[i] p i System.out.println(s) System.out.println System.out System System.out s String[] args args public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] p = new int[n];
        for(int i = 1 ; i <= n ; i++ ){
            p[i - 1] = sc.nextInt(); 
        }
        for(int i = 1; i <= n ; i++ ){
            for(int j = 0 ; j < n - 1 ; j++ ){
                if(p[j] > p[j + 1]){
                    int ko = p[j];
                    p[j] = p[j + 1];
                    p[j + 1] = ko;
                }
            }
        }
        int s = 0;
        for(int i = 0 ; i < k ; i++ ){
            s = s + p[i];
        }
        System.out.println(s);
    }
} public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] p = new int[n];
        for(int i = 1 ; i <= n ; i++ ){
            p[i - 1] = sc.nextInt(); 
        }
        for(int i = 1; i <= n ; i++ ){
            for(int j = 0 ; j < n - 1 ; j++ ){
                if(p[j] > p[j + 1]){
                    int ko = p[j];
                    p[j] = p[j + 1];
                    p[j + 1] = ko;
                }
            }
        }
        int s = 0;
        for(int i = 0 ; i < k ; i++ ){
            s = s + p[i];
        }
        System.out.println(s);
    }
} Main
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] p = new int[n];
        for(int i = 1 ; i <= n ; i++ ){
            p[i - 1] = sc.nextInt(); 
        }
        for(int i = 1; i <= n ; i++ ){
            for(int j = 0 ; j < n - 1 ; j++ ){
                if(p[j] > p[j + 1]){
                    int ko = p[j];
                    p[j] = p[j + 1];
                    p[j + 1] = ko;
                }
            }
        }
        int s = 0;
        for(int i = 0 ; i < k ; i++ ){
            s = s + p[i];
        }
        System.out.println(s);
    }
}