import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return str;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() { return Long.parseLong(next());  }
    }

    public static void main(String[] args) {
        FastReader sn = new FastReader();
        int N = sn.nextInt();
        int K = sn.nextInt();
        int []arr = new int[N];
        for(int i=0;i<N;i++) {
            arr[i] = sn.nextInt();
        }
        Arrays.sort(arr);
        int sum=0;
        for(int i=0;i<K;i++) {
            sum+=arr[i];
        }
        System.out.println(sum);
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.Arrays; Arrays java.util import java.util.StringTokenizer; StringTokenizer java.util public class Main {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return str;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() { return Long.parseLong(next());  }
    }

    public static void main(String[] args) {
        FastReader sn = new FastReader();
        int N = sn.nextInt();
        int K = sn.nextInt();
        int []arr = new int[N];
        for(int i=0;i<N;i++) {
            arr[i] = sn.nextInt();
        }
        Arrays.sort(arr);
        int sum=0;
        for(int i=0;i<K;i++) {
            sum+=arr[i];
        }
        System.out.println(sum);
    }
} Main public static void main(String[] args) {
        FastReader sn = new FastReader();
        int N = sn.nextInt();
        int K = sn.nextInt();
        int []arr = new int[N];
        for(int i=0;i<N;i++) {
            arr[i] = sn.nextInt();
        }
        Arrays.sort(arr);
        int sum=0;
        for(int i=0;i<K;i++) {
            sum+=arr[i];
        }
        System.out.println(sum);
    } main {
        FastReader sn = new FastReader();
        int N = sn.nextInt();
        int K = sn.nextInt();
        int []arr = new int[N];
        for(int i=0;i<N;i++) {
            arr[i] = sn.nextInt();
        }
        Arrays.sort(arr);
        int sum=0;
        for(int i=0;i<K;i++) {
            sum+=arr[i];
        }
        System.out.println(sum);
    } FastReader sn = new FastReader(); sn new FastReader() int N = sn.nextInt(); N sn.nextInt() sn.nextInt sn int K = sn.nextInt(); K sn.nextInt() sn.nextInt sn int []arr = new int[N]; arr new int[N] N for(int i=0;i<N;i++) {
            arr[i] = sn.nextInt();
        } int i=0; int i=0; i 0 i<N i N i++ i++ i {
            arr[i] = sn.nextInt();
        } {
            arr[i] = sn.nextInt();
        } arr[i] = sn.nextInt() arr[i] arr i sn.nextInt() sn.nextInt sn Arrays.sort(arr) Arrays.sort Arrays arr int sum=0; sum 0 for(int i=0;i<K;i++) {
            sum+=arr[i];
        } int i=0; int i=0; i 0 i<K i K i++ i++ i {
            sum+=arr[i];
        } {
            sum+=arr[i];
        } sum+=arr[i] sum arr[i] arr i System.out.println(sum) System.out.println System.out System System.out sum String[] args args static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return str;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() { return Long.parseLong(next());  }
    } FastReader BufferedReader br; br StringTokenizer st; st 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 (Exception e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        } next {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        } while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception 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 (Exception e) {
                    e.printStackTrace();
                }
            } try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    e.printStackTrace();
                } catch (Exception e) {
                    e.printStackTrace();
                } Exception 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 String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return str;
        } nextLine {
            String str = "";
            try {
                str = br.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return str;
        } String str = ""; str "" try {
                str = br.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            } catch (Exception e) {
                e.printStackTrace();
            } Exception e {
                e.printStackTrace();
            } e.printStackTrace() e.printStackTrace e {
                str = br.readLine();
            } str = br.readLine() str br.readLine() br.readLine br return str; str 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 public class Main {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return str;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() { return Long.parseLong(next());  }
    }

    public static void main(String[] args) {
        FastReader sn = new FastReader();
        int N = sn.nextInt();
        int K = sn.nextInt();
        int []arr = new int[N];
        for(int i=0;i<N;i++) {
            arr[i] = sn.nextInt();
        }
        Arrays.sort(arr);
        int sum=0;
        for(int i=0;i<K;i++) {
            sum+=arr[i];
        }
        System.out.println(sum);
    }
} public class Main {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return str;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() { return Long.parseLong(next());  }
    }

    public static void main(String[] args) {
        FastReader sn = new FastReader();
        int N = sn.nextInt();
        int K = sn.nextInt();
        int []arr = new int[N];
        for(int i=0;i<N;i++) {
            arr[i] = sn.nextInt();
        }
        Arrays.sort(arr);
        int sum=0;
        for(int i=0;i<K;i++) {
            sum+=arr[i];
        }
        System.out.println(sum);
    }
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return str;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() { return Long.parseLong(next());  }
    }

    public static void main(String[] args) {
        FastReader sn = new FastReader();
        int N = sn.nextInt();
        int K = sn.nextInt();
        int []arr = new int[N];
        for(int i=0;i<N;i++) {
            arr[i] = sn.nextInt();
        }
        Arrays.sort(arr);
        int sum=0;
        for(int i=0;i<K;i++) {
            sum+=arr[i];
        }
        System.out.println(sum);
    }
}