
import java.io.*;

import java.math.BigInteger;
import java.util.*;

import java.util.ArrayList;

import java.util.Scanner;


public class Main {

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

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

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

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

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

    static final int mod = 1000000007;
    static final int mod1 = 1073741824;

    public static int gcd(int a, int b) {
        if (a == 0)
            return b;
        return gcd(b % a, a);
    }

    static boolean prime[] = new boolean[1000001];

    public static void sieve() {
        int n = 1000000;

        Arrays.fill(prime, true);
        for (int j = 2; j * j <= n; j++) {
            if (prime[j] == true) {
                for (int i = j * j; i <= n; i += j) {
                    prime[i] = false;
                }
            }
        }
        /*for(int j=2;j<=n;j++)
        {
            if(prime[j]==true)
                System.out.println(j);
        }*/

    }

    public static void main(String[] args) {
        FastReader sc = new FastReader();
        //Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int k=sc.nextInt();
        int a[]=new int[n];
        HashMap<Integer,Integer>hm=new HashMap<>();
        for(int j=0;j<n;j++) {
            a[j] = sc.nextInt();

        }
        Arrays.sort(a);
        long ans=0;
        for(int j=0;j<k;j++)
            ans+=a[j];
        System.out.println(ans);



    }
}

















 import java.io.*; io.* java import java.math.BigInteger; BigInteger java.math import java.util.*; util.* java import java.util.ArrayList; ArrayList java.util import java.util.Scanner; Scanner java.util public class Main {

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

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

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

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

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

    static final int mod = 1000000007;
    static final int mod1 = 1073741824;

    public static int gcd(int a, int b) {
        if (a == 0)
            return b;
        return gcd(b % a, a);
    }

    static boolean prime[] = new boolean[1000001];

    public static void sieve() {
        int n = 1000000;

        Arrays.fill(prime, true);
        for (int j = 2; j * j <= n; j++) {
            if (prime[j] == true) {
                for (int i = j * j; i <= n; i += j) {
                    prime[i] = false;
                }
            }
        }
        /*for(int j=2;j<=n;j++)
        {
            if(prime[j]==true)
                System.out.println(j);
        }*/

    }

    public static void main(String[] args) {
        FastReader sc = new FastReader();
        //Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int k=sc.nextInt();
        int a[]=new int[n];
        HashMap<Integer,Integer>hm=new HashMap<>();
        for(int j=0;j<n;j++) {
            a[j] = sc.nextInt();

        }
        Arrays.sort(a);
        long ans=0;
        for(int j=0;j<k;j++)
            ans+=a[j];
        System.out.println(ans);



    }
} Main static final int mod = 1000000007; mod 1000000007 static final int mod1 = 1073741824; mod1 1073741824 static boolean prime[] = new boolean[1000001]; prime new boolean[1000001] 1000001 public static int gcd(int a, int b) {
        if (a == 0)
            return b;
        return gcd(b % a, a);
    } gcd {
        if (a == 0)
            return b;
        return gcd(b % a, a);
    } if (a == 0)
            return b; a == 0 a 0 return b; b return gcd(b % a, a); gcd(b % a, a) gcd b % a b a a int a a int b b public static void sieve() {
        int n = 1000000;

        Arrays.fill(prime, true);
        for (int j = 2; j * j <= n; j++) {
            if (prime[j] == true) {
                for (int i = j * j; i <= n; i += j) {
                    prime[i] = false;
                }
            }
        }
        /*for(int j=2;j<=n;j++)
        {
            if(prime[j]==true)
                System.out.println(j);
        }*/

    } sieve {
        int n = 1000000;

        Arrays.fill(prime, true);
        for (int j = 2; j * j <= n; j++) {
            if (prime[j] == true) {
                for (int i = j * j; i <= n; i += j) {
                    prime[i] = false;
                }
            }
        }
        /*for(int j=2;j<=n;j++)
        {
            if(prime[j]==true)
                System.out.println(j);
        }*/

    } int n = 1000000; n 1000000 Arrays.fill(prime, true) Arrays.fill Arrays prime true for (int j = 2; j * j <= n; j++) {
            if (prime[j] == true) {
                for (int i = j * j; i <= n; i += j) {
                    prime[i] = false;
                }
            }
        } int j = 2; int j = 2; j 2 j * j <= n j * j j j n j++ j++ j {
            if (prime[j] == true) {
                for (int i = j * j; i <= n; i += j) {
                    prime[i] = false;
                }
            }
        } {
            if (prime[j] == true) {
                for (int i = j * j; i <= n; i += j) {
                    prime[i] = false;
                }
            }
        } if (prime[j] == true) {
                for (int i = j * j; i <= n; i += j) {
                    prime[i] = false;
                }
            } prime[j] == true prime[j] prime j true {
                for (int i = j * j; i <= n; i += j) {
                    prime[i] = false;
                }
            } for (int i = j * j; i <= n; i += j) {
                    prime[i] = false;
                } int i = j * j; int i = j * j; i j * j j j i <= n i n i += j i += j i j {
                    prime[i] = false;
                } {
                    prime[i] = false;
                } prime[i] = false prime[i] prime i false public static void main(String[] args) {
        FastReader sc = new FastReader();
        //Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int k=sc.nextInt();
        int a[]=new int[n];
        HashMap<Integer,Integer>hm=new HashMap<>();
        for(int j=0;j<n;j++) {
            a[j] = sc.nextInt();

        }
        Arrays.sort(a);
        long ans=0;
        for(int j=0;j<k;j++)
            ans+=a[j];
        System.out.println(ans);



    } main {
        FastReader sc = new FastReader();
        //Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int k=sc.nextInt();
        int a[]=new int[n];
        HashMap<Integer,Integer>hm=new HashMap<>();
        for(int j=0;j<n;j++) {
            a[j] = sc.nextInt();

        }
        Arrays.sort(a);
        long ans=0;
        for(int j=0;j<k;j++)
            ans+=a[j];
        System.out.println(ans);



    } FastReader sc = new FastReader(); sc new FastReader() int n=sc.nextInt(); n sc.nextInt() sc.nextInt sc int k=sc.nextInt(); k sc.nextInt() sc.nextInt sc int a[]=new int[n]; a new int[n] n HashMap<Integer,Integer>hm=new HashMap<>(); hm new HashMap<>() for(int j=0;j<n;j++) {
            a[j] = sc.nextInt();

        } int j=0; int j=0; j 0 j<n j n j++ j++ j {
            a[j] = sc.nextInt();

        } {
            a[j] = sc.nextInt();

        } a[j] = sc.nextInt() a[j] a j sc.nextInt() sc.nextInt sc Arrays.sort(a) Arrays.sort Arrays a long ans=0; ans 0 for(int j=0;j<k;j++)
            ans+=a[j]; int j=0; int j=0; j 0 j<k j k j++ j++ j ans+=a[j]; ans+=a[j] ans a[j] a j System.out.println(ans) System.out.println System.out System System.out ans String[] args args static class FastReader {
        BufferedReader br;
        StringTokenizer st;

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

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

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    } FastReader BufferedReader br; br StringTokenizer st; st public 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 (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        } next {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        } while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException 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 (IOException e) {
                    e.printStackTrace();
                }
            } try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                } IOException 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 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 double nextDouble() {
            return Double.parseDouble(next());
        } nextDouble {
            return Double.parseDouble(next());
        } return Double.parseDouble(next()); Double.parseDouble(next()) Double.parseDouble Double next() next String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        } nextLine {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        } String str = ""; str "" try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            } IOException e {
                e.printStackTrace();
            } e.printStackTrace() e.printStackTrace e {
                str = br.readLine();
            } str = br.readLine() str br.readLine() br.readLine br return str; str public class Main {

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

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

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

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

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

    static final int mod = 1000000007;
    static final int mod1 = 1073741824;

    public static int gcd(int a, int b) {
        if (a == 0)
            return b;
        return gcd(b % a, a);
    }

    static boolean prime[] = new boolean[1000001];

    public static void sieve() {
        int n = 1000000;

        Arrays.fill(prime, true);
        for (int j = 2; j * j <= n; j++) {
            if (prime[j] == true) {
                for (int i = j * j; i <= n; i += j) {
                    prime[i] = false;
                }
            }
        }
        /*for(int j=2;j<=n;j++)
        {
            if(prime[j]==true)
                System.out.println(j);
        }*/

    }

    public static void main(String[] args) {
        FastReader sc = new FastReader();
        //Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int k=sc.nextInt();
        int a[]=new int[n];
        HashMap<Integer,Integer>hm=new HashMap<>();
        for(int j=0;j<n;j++) {
            a[j] = sc.nextInt();

        }
        Arrays.sort(a);
        long ans=0;
        for(int j=0;j<k;j++)
            ans+=a[j];
        System.out.println(ans);



    }
} public class Main {

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

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

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

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

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

    static final int mod = 1000000007;
    static final int mod1 = 1073741824;

    public static int gcd(int a, int b) {
        if (a == 0)
            return b;
        return gcd(b % a, a);
    }

    static boolean prime[] = new boolean[1000001];

    public static void sieve() {
        int n = 1000000;

        Arrays.fill(prime, true);
        for (int j = 2; j * j <= n; j++) {
            if (prime[j] == true) {
                for (int i = j * j; i <= n; i += j) {
                    prime[i] = false;
                }
            }
        }
        /*for(int j=2;j<=n;j++)
        {
            if(prime[j]==true)
                System.out.println(j);
        }*/

    }

    public static void main(String[] args) {
        FastReader sc = new FastReader();
        //Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int k=sc.nextInt();
        int a[]=new int[n];
        HashMap<Integer,Integer>hm=new HashMap<>();
        for(int j=0;j<n;j++) {
            a[j] = sc.nextInt();

        }
        Arrays.sort(a);
        long ans=0;
        for(int j=0;j<k;j++)
            ans+=a[j];
        System.out.println(ans);



    }
} Main

import java.io.*;

import java.math.BigInteger;
import java.util.*;

import java.util.ArrayList;

import java.util.Scanner;


public class Main {

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

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

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

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

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

    static final int mod = 1000000007;
    static final int mod1 = 1073741824;

    public static int gcd(int a, int b) {
        if (a == 0)
            return b;
        return gcd(b % a, a);
    }

    static boolean prime[] = new boolean[1000001];

    public static void sieve() {
        int n = 1000000;

        Arrays.fill(prime, true);
        for (int j = 2; j * j <= n; j++) {
            if (prime[j] == true) {
                for (int i = j * j; i <= n; i += j) {
                    prime[i] = false;
                }
            }
        }
        /*for(int j=2;j<=n;j++)
        {
            if(prime[j]==true)
                System.out.println(j);
        }*/

    }

    public static void main(String[] args) {
        FastReader sc = new FastReader();
        //Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int k=sc.nextInt();
        int a[]=new int[n];
        HashMap<Integer,Integer>hm=new HashMap<>();
        for(int j=0;j<n;j++) {
            a[j] = sc.nextInt();

        }
        Arrays.sort(a);
        long ans=0;
        for(int j=0;j<k;j++)
            ans+=a[j];
        System.out.println(ans);



    }
}


















