

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tokenizer = null;
    int totalCases, testNum;

    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

    void solve() throws IOException {

    }

    void execute() throws IOException {
        int n = ni();
        int k = ni();
        int[] arr = new int[n];
        for(int i = 0; i < n; i++) {
            arr[i] = ni();
        }
        Arrays.sort(arr);
        int res = 0;
        for (int i = 0; i < k; i++) {
            res += arr[i];
        }
        out.println(res);
        out.close();
    }

    public static void main(String[] args) throws IOException {
        new Main().execute();
    }

    void debug(Object... os) {
        System.out.println(Arrays.deepToString(os));
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String ns() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(br.readLine());
        }
        return tokenizer.nextToken();
    }

    String nline() throws IOException {
        tokenizer = null;
        return br.readLine();
    }

    boolean input() throws IOException {
        return true;
    }

} import java.io.BufferedReader; BufferedReader java.io import java.io.BufferedWriter; BufferedWriter java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.OutputStreamWriter; OutputStreamWriter java.io import java.io.PrintWriter; PrintWriter java.io import java.util.Arrays; Arrays java.util import java.util.StringTokenizer; StringTokenizer java.util public class Main {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tokenizer = null;
    int totalCases, testNum;

    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

    void solve() throws IOException {

    }

    void execute() throws IOException {
        int n = ni();
        int k = ni();
        int[] arr = new int[n];
        for(int i = 0; i < n; i++) {
            arr[i] = ni();
        }
        Arrays.sort(arr);
        int res = 0;
        for (int i = 0; i < k; i++) {
            res += arr[i];
        }
        out.println(res);
        out.close();
    }

    public static void main(String[] args) throws IOException {
        new Main().execute();
    }

    void debug(Object... os) {
        System.out.println(Arrays.deepToString(os));
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String ns() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(br.readLine());
        }
        return tokenizer.nextToken();
    }

    String nline() throws IOException {
        tokenizer = null;
        return br.readLine();
    }

    boolean input() throws IOException {
        return true;
    }

} Main BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) StringTokenizer tokenizer = null; tokenizer null int totalCases totalCases testNum; testNum PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); out new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))) void solve() throws IOException {

    } solve {

    } void execute() throws IOException {
        int n = ni();
        int k = ni();
        int[] arr = new int[n];
        for(int i = 0; i < n; i++) {
            arr[i] = ni();
        }
        Arrays.sort(arr);
        int res = 0;
        for (int i = 0; i < k; i++) {
            res += arr[i];
        }
        out.println(res);
        out.close();
    } execute {
        int n = ni();
        int k = ni();
        int[] arr = new int[n];
        for(int i = 0; i < n; i++) {
            arr[i] = ni();
        }
        Arrays.sort(arr);
        int res = 0;
        for (int i = 0; i < k; i++) {
            res += arr[i];
        }
        out.println(res);
        out.close();
    } int n = ni(); n ni() ni int k = ni(); k ni() ni int[] arr = new int[n]; arr new int[n] n for(int i = 0; i < n; i++) {
            arr[i] = ni();
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            arr[i] = ni();
        } {
            arr[i] = ni();
        } arr[i] = ni() arr[i] arr i ni() ni Arrays.sort(arr) Arrays.sort Arrays arr int res = 0; res 0 for (int i = 0; i < k; i++) {
            res += arr[i];
        } int i = 0; int i = 0; i 0 i < k i k i++ i++ i {
            res += arr[i];
        } {
            res += arr[i];
        } res += arr[i] res arr[i] arr i out.println(res) out.println out res out.close() out.close out public static void main(String[] args) throws IOException {
        new Main().execute();
    } main {
        new Main().execute();
    } new Main().execute() new Main().execute new Main() String[] args args void debug(Object... os) {
        System.out.println(Arrays.deepToString(os));
    } debug {
        System.out.println(Arrays.deepToString(os));
    } System.out.println(Arrays.deepToString(os)) System.out.println System.out System System.out Arrays.deepToString(os) Arrays.deepToString Arrays os Object... os os int ni() throws IOException {
        return Integer.parseInt(ns());
    } ni {
        return Integer.parseInt(ns());
    } return Integer.parseInt(ns()); Integer.parseInt(ns()) Integer.parseInt Integer ns() ns long nl() throws IOException {
        return Long.parseLong(ns());
    } nl {
        return Long.parseLong(ns());
    } return Long.parseLong(ns()); Long.parseLong(ns()) Long.parseLong Long ns() ns double nd() throws IOException {
        return Double.parseDouble(ns());
    } nd {
        return Double.parseDouble(ns());
    } return Double.parseDouble(ns()); Double.parseDouble(ns()) Double.parseDouble Double ns() ns String ns() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(br.readLine());
        }
        return tokenizer.nextToken();
    } ns {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(br.readLine());
        }
        return tokenizer.nextToken();
    } while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(br.readLine());
        } tokenizer == null || !tokenizer.hasMoreTokens() tokenizer == null tokenizer null !tokenizer.hasMoreTokens() tokenizer.hasMoreTokens() tokenizer.hasMoreTokens tokenizer {
            tokenizer = new StringTokenizer(br.readLine());
        } tokenizer = new StringTokenizer(br.readLine()) tokenizer new StringTokenizer(br.readLine()) return tokenizer.nextToken(); tokenizer.nextToken() tokenizer.nextToken tokenizer String nline() throws IOException {
        tokenizer = null;
        return br.readLine();
    } nline {
        tokenizer = null;
        return br.readLine();
    } tokenizer = null tokenizer null return br.readLine(); br.readLine() br.readLine br boolean input() throws IOException {
        return true;
    } input {
        return true;
    } return true; true public class Main {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tokenizer = null;
    int totalCases, testNum;

    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

    void solve() throws IOException {

    }

    void execute() throws IOException {
        int n = ni();
        int k = ni();
        int[] arr = new int[n];
        for(int i = 0; i < n; i++) {
            arr[i] = ni();
        }
        Arrays.sort(arr);
        int res = 0;
        for (int i = 0; i < k; i++) {
            res += arr[i];
        }
        out.println(res);
        out.close();
    }

    public static void main(String[] args) throws IOException {
        new Main().execute();
    }

    void debug(Object... os) {
        System.out.println(Arrays.deepToString(os));
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String ns() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(br.readLine());
        }
        return tokenizer.nextToken();
    }

    String nline() throws IOException {
        tokenizer = null;
        return br.readLine();
    }

    boolean input() throws IOException {
        return true;
    }

} public class Main {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tokenizer = null;
    int totalCases, testNum;

    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

    void solve() throws IOException {

    }

    void execute() throws IOException {
        int n = ni();
        int k = ni();
        int[] arr = new int[n];
        for(int i = 0; i < n; i++) {
            arr[i] = ni();
        }
        Arrays.sort(arr);
        int res = 0;
        for (int i = 0; i < k; i++) {
            res += arr[i];
        }
        out.println(res);
        out.close();
    }

    public static void main(String[] args) throws IOException {
        new Main().execute();
    }

    void debug(Object... os) {
        System.out.println(Arrays.deepToString(os));
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String ns() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(br.readLine());
        }
        return tokenizer.nextToken();
    }

    String nline() throws IOException {
        tokenizer = null;
        return br.readLine();
    }

    boolean input() throws IOException {
        return true;
    }

} Main


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tokenizer = null;
    int totalCases, testNum;

    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

    void solve() throws IOException {

    }

    void execute() throws IOException {
        int n = ni();
        int k = ni();
        int[] arr = new int[n];
        for(int i = 0; i < n; i++) {
            arr[i] = ni();
        }
        Arrays.sort(arr);
        int res = 0;
        for (int i = 0; i < k; i++) {
            res += arr[i];
        }
        out.println(res);
        out.close();
    }

    public static void main(String[] args) throws IOException {
        new Main().execute();
    }

    void debug(Object... os) {
        System.out.println(Arrays.deepToString(os));
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String ns() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(br.readLine());
        }
        return tokenizer.nextToken();
    }

    String nline() throws IOException {
        tokenizer = null;
        return br.readLine();
    }

    boolean input() throws IOException {
        return true;
    }

}
