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];
        int c = 0;
        for (int i = 0; i < N; i++) {
            p[i] = sc.nextInt();
        }
        for(int i=0; i < p.length-1; i++) {
            for(int j=0; j < p.length-i-1; j++) {
            	if(p[j] > p[j+1]) {
            		int asc = p[j];
            		p[j] = p[j+1];
                    p[j+1] = asc;
                }
            }
        }
        for (int i = 0; i < K; i++) {
            c = c + p[i];
        }
        System.out.println(c);
    }
} 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];
        int c = 0;
        for (int i = 0; i < N; i++) {
            p[i] = sc.nextInt();
        }
        for(int i=0; i < p.length-1; i++) {
            for(int j=0; j < p.length-i-1; j++) {
            	if(p[j] > p[j+1]) {
            		int asc = p[j];
            		p[j] = p[j+1];
                    p[j+1] = asc;
                }
            }
        }
        for (int i = 0; i < K; i++) {
            c = c + p[i];
        }
        System.out.println(c);
    }
} 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];
        int c = 0;
        for (int i = 0; i < N; i++) {
            p[i] = sc.nextInt();
        }
        for(int i=0; i < p.length-1; i++) {
            for(int j=0; j < p.length-i-1; j++) {
            	if(p[j] > p[j+1]) {
            		int asc = p[j];
            		p[j] = p[j+1];
                    p[j+1] = asc;
                }
            }
        }
        for (int i = 0; i < K; i++) {
            c = c + p[i];
        }
        System.out.println(c);
    } main {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] p = new int[N];
        int c = 0;
        for (int i = 0; i < N; i++) {
            p[i] = sc.nextInt();
        }
        for(int i=0; i < p.length-1; i++) {
            for(int j=0; j < p.length-i-1; j++) {
            	if(p[j] > p[j+1]) {
            		int asc = p[j];
            		p[j] = p[j+1];
                    p[j+1] = asc;
                }
            }
        }
        for (int i = 0; i < K; i++) {
            c = c + p[i];
        }
        System.out.println(c);
    } 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 int c = 0; c 0 for (int i = 0; i < N; i++) {
            p[i] = sc.nextInt();
        } int i = 0; int 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(int i=0; i < p.length-1; i++) {
            for(int j=0; j < p.length-i-1; j++) {
            	if(p[j] > p[j+1]) {
            		int asc = p[j];
            		p[j] = p[j+1];
                    p[j+1] = asc;
                }
            }
        } int i=0; int i=0; i 0 i < p.length-1 i p.length-1 p.length p p.length 1 i++ i++ i {
            for(int j=0; j < p.length-i-1; j++) {
            	if(p[j] > p[j+1]) {
            		int asc = p[j];
            		p[j] = p[j+1];
                    p[j+1] = asc;
                }
            }
        } {
            for(int j=0; j < p.length-i-1; j++) {
            	if(p[j] > p[j+1]) {
            		int asc = p[j];
            		p[j] = p[j+1];
                    p[j+1] = asc;
                }
            }
        } for(int j=0; j < p.length-i-1; j++) {
            	if(p[j] > p[j+1]) {
            		int asc = p[j];
            		p[j] = p[j+1];
                    p[j+1] = asc;
                }
            } int j=0; int j=0; j 0 j < p.length-i-1 j p.length-i-1 p.length-i-1 p.length p p.length i 1 j++ j++ j {
            	if(p[j] > p[j+1]) {
            		int asc = p[j];
            		p[j] = p[j+1];
                    p[j+1] = asc;
                }
            } {
            	if(p[j] > p[j+1]) {
            		int asc = p[j];
            		p[j] = p[j+1];
                    p[j+1] = asc;
                }
            } if(p[j] > p[j+1]) {
            		int asc = p[j];
            		p[j] = p[j+1];
                    p[j+1] = asc;
                } p[j] > p[j+1] p[j] p j p[j+1] p j+1 j 1 {
            		int asc = p[j];
            		p[j] = p[j+1];
                    p[j+1] = asc;
                } int asc = p[j]; asc p[j] p j p[j] = p[j+1] p[j] p j p[j+1] p j+1 j 1 p[j+1] = asc p[j+1] p j+1 j 1 asc for (int i = 0; i < K; i++) {
            c = c + p[i];
        } int i = 0; int i = 0; i 0 i < K i K i++ i++ i {
            c = c + p[i];
        } {
            c = c + p[i];
        } c = c + p[i] c c + p[i] c p[i] p i System.out.println(c) System.out.println System.out System System.out c 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];
        int c = 0;
        for (int i = 0; i < N; i++) {
            p[i] = sc.nextInt();
        }
        for(int i=0; i < p.length-1; i++) {
            for(int j=0; j < p.length-i-1; j++) {
            	if(p[j] > p[j+1]) {
            		int asc = p[j];
            		p[j] = p[j+1];
                    p[j+1] = asc;
                }
            }
        }
        for (int i = 0; i < K; i++) {
            c = c + p[i];
        }
        System.out.println(c);
    }
} 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];
        int c = 0;
        for (int i = 0; i < N; i++) {
            p[i] = sc.nextInt();
        }
        for(int i=0; i < p.length-1; i++) {
            for(int j=0; j < p.length-i-1; j++) {
            	if(p[j] > p[j+1]) {
            		int asc = p[j];
            		p[j] = p[j+1];
                    p[j+1] = asc;
                }
            }
        }
        for (int i = 0; i < K; i++) {
            c = c + p[i];
        }
        System.out.println(c);
    }
} 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];
        int c = 0;
        for (int i = 0; i < N; i++) {
            p[i] = sc.nextInt();
        }
        for(int i=0; i < p.length-1; i++) {
            for(int j=0; j < p.length-i-1; j++) {
            	if(p[j] > p[j+1]) {
            		int asc = p[j];
            		p[j] = p[j+1];
                    p[j+1] = asc;
                }
            }
        }
        for (int i = 0; i < K; i++) {
            c = c + p[i];
        }
        System.out.println(c);
    }
}