import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());

        int N = Integer.parseInt(st.nextToken());
        int K = Integer.parseInt(st.nextToken());

        st = new StringTokenizer(br.readLine());
        int[] price_array = new int[N];

        int result = 0;

        for(int i = 0; i < N; i++) {
            price_array[i] = Integer.parseInt(st.nextToken());
        }

        Arrays.sort(price_array);

        for(int j = 0; j < K; j++) {
            result += price_array[j];
        }
        
        pw.println(result);
        br.close();
        pw.close();
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException 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 {
    
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());

        int N = Integer.parseInt(st.nextToken());
        int K = Integer.parseInt(st.nextToken());

        st = new StringTokenizer(br.readLine());
        int[] price_array = new int[N];

        int result = 0;

        for(int i = 0; i < N; i++) {
            price_array[i] = Integer.parseInt(st.nextToken());
        }

        Arrays.sort(price_array);

        for(int j = 0; j < K; j++) {
            result += price_array[j];
        }
        
        pw.println(result);
        br.close();
        pw.close();
    }
} Main public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());

        int N = Integer.parseInt(st.nextToken());
        int K = Integer.parseInt(st.nextToken());

        st = new StringTokenizer(br.readLine());
        int[] price_array = new int[N];

        int result = 0;

        for(int i = 0; i < N; i++) {
            price_array[i] = Integer.parseInt(st.nextToken());
        }

        Arrays.sort(price_array);

        for(int j = 0; j < K; j++) {
            result += price_array[j];
        }
        
        pw.println(result);
        br.close();
        pw.close();
    } main {
        BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());

        int N = Integer.parseInt(st.nextToken());
        int K = Integer.parseInt(st.nextToken());

        st = new StringTokenizer(br.readLine());
        int[] price_array = new int[N];

        int result = 0;

        for(int i = 0; i < N; i++) {
            price_array[i] = Integer.parseInt(st.nextToken());
        }

        Arrays.sort(price_array);

        for(int j = 0; j < K; j++) {
            result += price_array[j];
        }
        
        pw.println(result);
        br.close();
        pw.close();
    } BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in)); br new BufferedReader(new java.io.InputStreamReader(System.in)) PrintWriter pw = new PrintWriter(System.out); pw new PrintWriter(System.out) StringTokenizer st = new StringTokenizer(br.readLine()); st new StringTokenizer(br.readLine()) int N = Integer.parseInt(st.nextToken()); N Integer.parseInt(st.nextToken()) Integer.parseInt Integer st.nextToken() st.nextToken st int K = Integer.parseInt(st.nextToken()); K Integer.parseInt(st.nextToken()) Integer.parseInt Integer st.nextToken() st.nextToken st st = new StringTokenizer(br.readLine()) st new StringTokenizer(br.readLine()) int[] price_array = new int[N]; price_array new int[N] N int result = 0; result 0 for(int i = 0; i < N; i++) {
            price_array[i] = Integer.parseInt(st.nextToken());
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            price_array[i] = Integer.parseInt(st.nextToken());
        } {
            price_array[i] = Integer.parseInt(st.nextToken());
        } price_array[i] = Integer.parseInt(st.nextToken()) price_array[i] price_array i Integer.parseInt(st.nextToken()) Integer.parseInt Integer st.nextToken() st.nextToken st Arrays.sort(price_array) Arrays.sort Arrays price_array for(int j = 0; j < K; j++) {
            result += price_array[j];
        } int j = 0; int j = 0; j 0 j < K j K j++ j++ j {
            result += price_array[j];
        } {
            result += price_array[j];
        } result += price_array[j] result price_array[j] price_array j pw.println(result) pw.println pw result br.close() br.close br pw.close() pw.close pw String[] args args public class Main {
    
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());

        int N = Integer.parseInt(st.nextToken());
        int K = Integer.parseInt(st.nextToken());

        st = new StringTokenizer(br.readLine());
        int[] price_array = new int[N];

        int result = 0;

        for(int i = 0; i < N; i++) {
            price_array[i] = Integer.parseInt(st.nextToken());
        }

        Arrays.sort(price_array);

        for(int j = 0; j < K; j++) {
            result += price_array[j];
        }
        
        pw.println(result);
        br.close();
        pw.close();
    }
} public class Main {
    
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());

        int N = Integer.parseInt(st.nextToken());
        int K = Integer.parseInt(st.nextToken());

        st = new StringTokenizer(br.readLine());
        int[] price_array = new int[N];

        int result = 0;

        for(int i = 0; i < N; i++) {
            price_array[i] = Integer.parseInt(st.nextToken());
        }

        Arrays.sort(price_array);

        for(int j = 0; j < K; j++) {
            result += price_array[j];
        }
        
        pw.println(result);
        br.close();
        pw.close();
    }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());

        int N = Integer.parseInt(st.nextToken());
        int K = Integer.parseInt(st.nextToken());

        st = new StringTokenizer(br.readLine());
        int[] price_array = new int[N];

        int result = 0;

        for(int i = 0; i < N; i++) {
            price_array[i] = Integer.parseInt(st.nextToken());
        }

        Arrays.sort(price_array);

        for(int j = 0; j < K; j++) {
            result += price_array[j];
        }
        
        pw.println(result);
        br.close();
        pw.close();
    }
}