//package atcoder.beginner_171;

import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    public static void main (String[] args) throws Exception {

        String s = "5 3\n" +
                "50 100 80 120 80";

//        br = new BufferedReader(new StringReader(s));
        br = new BufferedReader(new InputStreamReader(System.in));
        bw = new BufferedWriter(new OutputStreamWriter(System.out));

        rl(); int N=nin(), K=nin();
        rl(); int[] A=new int[N]; for(int i=0; i<A.length; ++i) A[i]=nin();
        Arrays.parallelSort(A);
        int sum=0;
        for(int i=0; i<K; ++i) sum+=A[i];


        bw.write(Integer.toString(sum));
        bw.newLine();
        bw.flush();

    }

    static BufferedReader br;
    static BufferedWriter bw;
    static StringTokenizer st;
    static void rl() throws Exception{
        st = new StringTokenizer(br.readLine());
    }
    static long nlo(){
        return Long.parseLong(st.nextToken());
    }
    static int nin(){
        return Integer.parseInt(st.nextToken());
    }
    /*private static void te(){
      }*/
    static double ndo(){
        return Double.parseDouble(st.nextToken());
    }
    static char[] nca(){
        return st.nextToken().toCharArray();
    }
    static String nstr(){
        return st.nextToken();
    }
} import java.io.*; io.* java import java.util.Arrays; Arrays java.util import java.util.StringTokenizer; StringTokenizer java.util public class Main {

    public static void main (String[] args) throws Exception {

        String s = "5 3\n" +
                "50 100 80 120 80";

//        br = new BufferedReader(new StringReader(s));
        br = new BufferedReader(new InputStreamReader(System.in));
        bw = new BufferedWriter(new OutputStreamWriter(System.out));

        rl(); int N=nin(), K=nin();
        rl(); int[] A=new int[N]; for(int i=0; i<A.length; ++i) A[i]=nin();
        Arrays.parallelSort(A);
        int sum=0;
        for(int i=0; i<K; ++i) sum+=A[i];


        bw.write(Integer.toString(sum));
        bw.newLine();
        bw.flush();

    }

    static BufferedReader br;
    static BufferedWriter bw;
    static StringTokenizer st;
    static void rl() throws Exception{
        st = new StringTokenizer(br.readLine());
    }
    static long nlo(){
        return Long.parseLong(st.nextToken());
    }
    static int nin(){
        return Integer.parseInt(st.nextToken());
    }
    /*private static void te(){
      }*/
    static double ndo(){
        return Double.parseDouble(st.nextToken());
    }
    static char[] nca(){
        return st.nextToken().toCharArray();
    }
    static String nstr(){
        return st.nextToken();
    }
} Main static BufferedReader br; br static BufferedWriter bw; bw static StringTokenizer st; st public static void main (String[] args) throws Exception {

        String s = "5 3\n" +
                "50 100 80 120 80";

//        br = new BufferedReader(new StringReader(s));
        br = new BufferedReader(new InputStreamReader(System.in));
        bw = new BufferedWriter(new OutputStreamWriter(System.out));

        rl(); int N=nin(), K=nin();
        rl(); int[] A=new int[N]; for(int i=0; i<A.length; ++i) A[i]=nin();
        Arrays.parallelSort(A);
        int sum=0;
        for(int i=0; i<K; ++i) sum+=A[i];


        bw.write(Integer.toString(sum));
        bw.newLine();
        bw.flush();

    } main {

        String s = "5 3\n" +
                "50 100 80 120 80";

//        br = new BufferedReader(new StringReader(s));
        br = new BufferedReader(new InputStreamReader(System.in));
        bw = new BufferedWriter(new OutputStreamWriter(System.out));

        rl(); int N=nin(), K=nin();
        rl(); int[] A=new int[N]; for(int i=0; i<A.length; ++i) A[i]=nin();
        Arrays.parallelSort(A);
        int sum=0;
        for(int i=0; i<K; ++i) sum+=A[i];


        bw.write(Integer.toString(sum));
        bw.newLine();
        bw.flush();

    } String s = "5 3\n" +
                "50 100 80 120 80"; s "5 3\n" +
                "50 100 80 120 80" "5 3\n" "50 100 80 120 80" br = new BufferedReader(new InputStreamReader(System.in)) br new BufferedReader(new InputStreamReader(System.in)) bw = new BufferedWriter(new OutputStreamWriter(System.out)) bw new BufferedWriter(new OutputStreamWriter(System.out)) rl() rl int N=nin() N nin() nin K=nin(); K nin() nin rl() rl int[] A=new int[N]; A new int[N] N for(int i=0; i<A.length; ++i) A[i]=nin(); int i=0; int i=0; i 0 i<A.length i A.length A A.length ++i ++i i A[i]=nin(); A[i]=nin() A[i] A i nin() nin Arrays.parallelSort(A) Arrays.parallelSort Arrays A int sum=0; sum 0 for(int i=0; i<K; ++i) sum+=A[i]; int i=0; int i=0; i 0 i<K i K ++i ++i i sum+=A[i]; sum+=A[i] sum A[i] A i bw.write(Integer.toString(sum)) bw.write bw Integer.toString(sum) Integer.toString Integer sum bw.newLine() bw.newLine bw bw.flush() bw.flush bw String[] args args static void rl() throws Exception{
        st = new StringTokenizer(br.readLine());
    } rl {
        st = new StringTokenizer(br.readLine());
    } st = new StringTokenizer(br.readLine()) st new StringTokenizer(br.readLine()) static long nlo(){
        return Long.parseLong(st.nextToken());
    } nlo {
        return Long.parseLong(st.nextToken());
    } return Long.parseLong(st.nextToken()); Long.parseLong(st.nextToken()) Long.parseLong Long st.nextToken() st.nextToken st static int nin(){
        return Integer.parseInt(st.nextToken());
    } nin {
        return Integer.parseInt(st.nextToken());
    } return Integer.parseInt(st.nextToken()); Integer.parseInt(st.nextToken()) Integer.parseInt Integer st.nextToken() st.nextToken st /*private static void te(){
      }*/
    static double ndo(){
        return Double.parseDouble(st.nextToken());
    } ndo {
        return Double.parseDouble(st.nextToken());
    } return Double.parseDouble(st.nextToken()); Double.parseDouble(st.nextToken()) Double.parseDouble Double st.nextToken() st.nextToken st static char[] nca(){
        return st.nextToken().toCharArray();
    } nca {
        return st.nextToken().toCharArray();
    } return st.nextToken().toCharArray(); st.nextToken().toCharArray() st.nextToken().toCharArray st.nextToken() st.nextToken st static String nstr(){
        return st.nextToken();
    } nstr {
        return st.nextToken();
    } return st.nextToken(); st.nextToken() st.nextToken st public class Main {

    public static void main (String[] args) throws Exception {

        String s = "5 3\n" +
                "50 100 80 120 80";

//        br = new BufferedReader(new StringReader(s));
        br = new BufferedReader(new InputStreamReader(System.in));
        bw = new BufferedWriter(new OutputStreamWriter(System.out));

        rl(); int N=nin(), K=nin();
        rl(); int[] A=new int[N]; for(int i=0; i<A.length; ++i) A[i]=nin();
        Arrays.parallelSort(A);
        int sum=0;
        for(int i=0; i<K; ++i) sum+=A[i];


        bw.write(Integer.toString(sum));
        bw.newLine();
        bw.flush();

    }

    static BufferedReader br;
    static BufferedWriter bw;
    static StringTokenizer st;
    static void rl() throws Exception{
        st = new StringTokenizer(br.readLine());
    }
    static long nlo(){
        return Long.parseLong(st.nextToken());
    }
    static int nin(){
        return Integer.parseInt(st.nextToken());
    }
    /*private static void te(){
      }*/
    static double ndo(){
        return Double.parseDouble(st.nextToken());
    }
    static char[] nca(){
        return st.nextToken().toCharArray();
    }
    static String nstr(){
        return st.nextToken();
    }
} public class Main {

    public static void main (String[] args) throws Exception {

        String s = "5 3\n" +
                "50 100 80 120 80";

//        br = new BufferedReader(new StringReader(s));
        br = new BufferedReader(new InputStreamReader(System.in));
        bw = new BufferedWriter(new OutputStreamWriter(System.out));

        rl(); int N=nin(), K=nin();
        rl(); int[] A=new int[N]; for(int i=0; i<A.length; ++i) A[i]=nin();
        Arrays.parallelSort(A);
        int sum=0;
        for(int i=0; i<K; ++i) sum+=A[i];


        bw.write(Integer.toString(sum));
        bw.newLine();
        bw.flush();

    }

    static BufferedReader br;
    static BufferedWriter bw;
    static StringTokenizer st;
    static void rl() throws Exception{
        st = new StringTokenizer(br.readLine());
    }
    static long nlo(){
        return Long.parseLong(st.nextToken());
    }
    static int nin(){
        return Integer.parseInt(st.nextToken());
    }
    /*private static void te(){
      }*/
    static double ndo(){
        return Double.parseDouble(st.nextToken());
    }
    static char[] nca(){
        return st.nextToken().toCharArray();
    }
    static String nstr(){
        return st.nextToken();
    }
} Main
//package atcoder.beginner_171;

import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    public static void main (String[] args) throws Exception {

        String s = "5 3\n" +
                "50 100 80 120 80";

//        br = new BufferedReader(new StringReader(s));
        br = new BufferedReader(new InputStreamReader(System.in));
        bw = new BufferedWriter(new OutputStreamWriter(System.out));

        rl(); int N=nin(), K=nin();
        rl(); int[] A=new int[N]; for(int i=0; i<A.length; ++i) A[i]=nin();
        Arrays.parallelSort(A);
        int sum=0;
        for(int i=0; i<K; ++i) sum+=A[i];


        bw.write(Integer.toString(sum));
        bw.newLine();
        bw.flush();

    }

    static BufferedReader br;
    static BufferedWriter bw;
    static StringTokenizer st;
    static void rl() throws Exception{
        st = new StringTokenizer(br.readLine());
    }
    static long nlo(){
        return Long.parseLong(st.nextToken());
    }
    static int nin(){
        return Integer.parseInt(st.nextToken());
    }
    /*private static void te(){
      }*/
    static double ndo(){
        return Double.parseDouble(st.nextToken());
    }
    static char[] nca(){
        return st.nextToken().toCharArray();
    }
    static String nstr(){
        return st.nextToken();
    }
}