import java.io.CharArrayReader;
import java.lang.reflect.Array;
import 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 s = 0;
        ArrayList<Integer> arr = new ArrayList<Integer>();
        for(int i=0;i<n;i++)arr.add(sc.nextInt());
        Collections.sort(arr);
        for(int j=0;j<k;j++)s += arr.get(j);
        System.out.println(s);
    }
} import java.io.CharArrayReader; CharArrayReader java.io import java.lang.reflect.Array; Array java.lang.reflect import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int s = 0;
        ArrayList<Integer> arr = new ArrayList<Integer>();
        for(int i=0;i<n;i++)arr.add(sc.nextInt());
        Collections.sort(arr);
        for(int j=0;j<k;j++)s += arr.get(j);
        System.out.println(s);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int s = 0;
        ArrayList<Integer> arr = new ArrayList<Integer>();
        for(int i=0;i<n;i++)arr.add(sc.nextInt());
        Collections.sort(arr);
        for(int j=0;j<k;j++)s += arr.get(j);
        System.out.println(s);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int s = 0;
        ArrayList<Integer> arr = new ArrayList<Integer>();
        for(int i=0;i<n;i++)arr.add(sc.nextInt());
        Collections.sort(arr);
        for(int j=0;j<k;j++)s += arr.get(j);
        System.out.println(s);
    } 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 s = 0; s 0 ArrayList<Integer> arr = new ArrayList<Integer>(); arr new ArrayList<Integer>() for(int i=0;i<n;i++)arr.add(sc.nextInt()); int i=0; int i=0; i 0 i<n i n i++ i++ i arr.add(sc.nextInt()); arr.add(sc.nextInt()) arr.add arr sc.nextInt() sc.nextInt sc Collections.sort(arr) Collections.sort Collections arr for(int j=0;j<k;j++)s += arr.get(j); int j=0; int j=0; j 0 j<k j k j++ j++ j s += arr.get(j); s += arr.get(j) s arr.get(j) arr.get arr j System.out.println(s) System.out.println System.out System System.out s 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 s = 0;
        ArrayList<Integer> arr = new ArrayList<Integer>();
        for(int i=0;i<n;i++)arr.add(sc.nextInt());
        Collections.sort(arr);
        for(int j=0;j<k;j++)s += arr.get(j);
        System.out.println(s);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int s = 0;
        ArrayList<Integer> arr = new ArrayList<Integer>();
        for(int i=0;i<n;i++)arr.add(sc.nextInt());
        Collections.sort(arr);
        for(int j=0;j<k;j++)s += arr.get(j);
        System.out.println(s);
    }
} Main
import java.io.CharArrayReader;
import java.lang.reflect.Array;
import 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 s = 0;
        ArrayList<Integer> arr = new ArrayList<Integer>();
        for(int i=0;i<n;i++)arr.add(sc.nextInt());
        Collections.sort(arr);
        for(int j=0;j<k;j++)s += arr.get(j);
        System.out.println(s);
    }
}
