import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n, k,i,tmp,j,sum=0;

        n = sc.nextInt();
        k = sc.nextInt();

        int p[] = new int[n];

        for (i = 0; i < n; i++) {
            p[i] = sc.nextInt();
        }

        for (i = 0; i < n - 1; i++) {
            for (j = i + 1; j < n; j++) {
                if (p[i] > p[j]) {
                    tmp = p[i];
                    p[i] = p[j];
                    p[j] = tmp;
                }
            }
        }
        for (i = 0; i < k; i++) {
            sum += p[i];
        }
        System.out.println(sum);
    }

} import java.util.*; util.* java class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n, k,i,tmp,j,sum=0;

        n = sc.nextInt();
        k = sc.nextInt();

        int p[] = new int[n];

        for (i = 0; i < n; i++) {
            p[i] = sc.nextInt();
        }

        for (i = 0; i < n - 1; i++) {
            for (j = i + 1; j < n; j++) {
                if (p[i] > p[j]) {
                    tmp = p[i];
                    p[i] = p[j];
                    p[j] = tmp;
                }
            }
        }
        for (i = 0; i < k; i++) {
            sum += p[i];
        }
        System.out.println(sum);
    }

} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n, k,i,tmp,j,sum=0;

        n = sc.nextInt();
        k = sc.nextInt();

        int p[] = new int[n];

        for (i = 0; i < n; i++) {
            p[i] = sc.nextInt();
        }

        for (i = 0; i < n - 1; i++) {
            for (j = i + 1; j < n; j++) {
                if (p[i] > p[j]) {
                    tmp = p[i];
                    p[i] = p[j];
                    p[j] = tmp;
                }
            }
        }
        for (i = 0; i < k; i++) {
            sum += p[i];
        }
        System.out.println(sum);
    } main {
        Scanner sc = new Scanner(System.in);
        int n, k,i,tmp,j,sum=0;

        n = sc.nextInt();
        k = sc.nextInt();

        int p[] = new int[n];

        for (i = 0; i < n; i++) {
            p[i] = sc.nextInt();
        }

        for (i = 0; i < n - 1; i++) {
            for (j = i + 1; j < n; j++) {
                if (p[i] > p[j]) {
                    tmp = p[i];
                    p[i] = p[j];
                    p[j] = tmp;
                }
            }
        }
        for (i = 0; i < k; i++) {
            sum += p[i];
        }
        System.out.println(sum);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n n k k i i tmp tmp j j sum=0; sum 0 n = sc.nextInt() n sc.nextInt() sc.nextInt sc k = sc.nextInt() k sc.nextInt() sc.nextInt sc int p[] = new int[n]; p new int[n] n for (i = 0; i < n; i++) {
            p[i] = sc.nextInt();
        } i = 0; i = 0 i 0 i < n i n i++ i++ i {
            p[i] = sc.nextInt();
        } {
            p[i] = sc.nextInt();
        } p[i] = sc.nextInt() p[i] p i sc.nextInt() sc.nextInt sc for (i = 0; i < n - 1; i++) {
            for (j = i + 1; j < n; j++) {
                if (p[i] > p[j]) {
                    tmp = p[i];
                    p[i] = p[j];
                    p[j] = tmp;
                }
            }
        } i = 0; i = 0 i 0 i < n - 1 i n - 1 n 1 i++ i++ i {
            for (j = i + 1; j < n; j++) {
                if (p[i] > p[j]) {
                    tmp = p[i];
                    p[i] = p[j];
                    p[j] = tmp;
                }
            }
        } {
            for (j = i + 1; j < n; j++) {
                if (p[i] > p[j]) {
                    tmp = p[i];
                    p[i] = p[j];
                    p[j] = tmp;
                }
            }
        } for (j = i + 1; j < n; j++) {
                if (p[i] > p[j]) {
                    tmp = p[i];
                    p[i] = p[j];
                    p[j] = tmp;
                }
            } j = i + 1; j = i + 1 j i + 1 i 1 j < n j n j++ j++ j {
                if (p[i] > p[j]) {
                    tmp = p[i];
                    p[i] = p[j];
                    p[j] = tmp;
                }
            } {
                if (p[i] > p[j]) {
                    tmp = p[i];
                    p[i] = p[j];
                    p[j] = tmp;
                }
            } if (p[i] > p[j]) {
                    tmp = p[i];
                    p[i] = p[j];
                    p[j] = tmp;
                } p[i] > p[j] p[i] p i p[j] p j {
                    tmp = p[i];
                    p[i] = p[j];
                    p[j] = tmp;
                } tmp = p[i] tmp p[i] p i p[i] = p[j] p[i] p i p[j] p j p[j] = tmp p[j] p j tmp for (i = 0; i < k; i++) {
            sum += p[i];
        } i = 0; i = 0 i 0 i < k i k i++ i++ i {
            sum += p[i];
        } {
            sum += p[i];
        } sum += p[i] sum p[i] p i System.out.println(sum) System.out.println System.out System System.out sum String[] args args
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n, k,i,tmp,j,sum=0;

        n = sc.nextInt();
        k = sc.nextInt();

        int p[] = new int[n];

        for (i = 0; i < n; i++) {
            p[i] = sc.nextInt();
        }

        for (i = 0; i < n - 1; i++) {
            for (j = i + 1; j < n; j++) {
                if (p[i] > p[j]) {
                    tmp = p[i];
                    p[i] = p[j];
                    p[j] = tmp;
                }
            }
        }
        for (i = 0; i < k; i++) {
            sum += p[i];
        }
        System.out.println(sum);
    }

}