/*
    Author: @__goku__
            ssrivastava990@gmail.com
 
                   `\-.   `
                      \ `.  `
                       \  \ |
              __.._    |   \.       S O N - G O K U
       ..---~~     ~ . |    Y
         ~-.          `|    |
            `.               `~~--.
              \                    ~.
               \                     \__. . -- -  .
         .-~~~~~      ,    ,            ~~~~~~---...._
      .-~___        ,'/  ,'/ ,'\          __...---~~~
            ~-.    /._\_( ,(/_. 7,-.    ~~---...__
           _...>-  P""6=`_/"6"~   6)    ___...--~~~
            ~~--._ \`--') `---'   9'  _..--~~~
                  ~\ ~~/_  ~~~   /`-.--~~
                    `.  ---    .'   \_
                      `. " _.-'     | ~-.,-------._
                  ..._../~~   ./       .-'    .-~~~-.
            ,--~~~ ,'...\` _./.----~~.'/    /'       `-
        _.-(      |\    `/~ _____..-' /    /      _.-~~`.
       /   |     /. ^---~~~~       ' /    /     ,'  ~.   \
      (    /    (  .           _ ' /'    /    ,/      \   )
      (`. |     `\   - - - - ~   /'      (   /         .  |
       \.\|       \            /'        \  |`.           /
       /.'\\      `\         /'           ~-\         .  /\
      /,   (        `\     /'                `.___..-      \
     | |    \         `\_/'                  //      \.     |
     | |     |                 _Seal_      /' |       |     |
 */

import java.io.*;
import java.util.*;

public class Main
{
    static PrintWriter out = new PrintWriter((System.out));

    public static void main(String args[]) throws IOException
    {
        Kioken sc = new Kioken();
        int n=sc.nextInt();
        int k=sc.nextInt();
        int ar[]=new int[n];
        for(int x=0;x<n;x++)
        {
            ar[x]=sc.nextInt();
        }
        Arrays.parallelSort(ar);
        int sum=0;
        for(int x=0;x<k;x++)
        {
            sum+=ar[x];
        }
        out.println(sum);
        out.close();
    }

    public static void kamehameha()
    {
    }

    static class Kioken
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        public String next()
        {
            while (!st.hasMoreTokens())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        public String nextLine()
        {
            try
            {
                return br.readLine();
            } catch (Exception e)
            {
                e.printStackTrace();
            }
            return null;
        }

        public boolean hasNext()
        {
            String next = null;
            try
            {
                next = br.readLine();
            } catch (Exception e)
            {
            }
            if (next == null)
            {
                return false;
            }
            st = new StringTokenizer(next);
            return true;
        }
    }
} import java.io.*; io.* java import java.util.*; util.* java public class Main
{
    static PrintWriter out = new PrintWriter((System.out));

    public static void main(String args[]) throws IOException
    {
        Kioken sc = new Kioken();
        int n=sc.nextInt();
        int k=sc.nextInt();
        int ar[]=new int[n];
        for(int x=0;x<n;x++)
        {
            ar[x]=sc.nextInt();
        }
        Arrays.parallelSort(ar);
        int sum=0;
        for(int x=0;x<k;x++)
        {
            sum+=ar[x];
        }
        out.println(sum);
        out.close();
    }

    public static void kamehameha()
    {
    }

    static class Kioken
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        public String next()
        {
            while (!st.hasMoreTokens())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        public String nextLine()
        {
            try
            {
                return br.readLine();
            } catch (Exception e)
            {
                e.printStackTrace();
            }
            return null;
        }

        public boolean hasNext()
        {
            String next = null;
            try
            {
                next = br.readLine();
            } catch (Exception e)
            {
            }
            if (next == null)
            {
                return false;
            }
            st = new StringTokenizer(next);
            return true;
        }
    }
} Main static PrintWriter out = new PrintWriter((System.out)); out new PrintWriter((System.out)) public static void main(String args[]) throws IOException
    {
        Kioken sc = new Kioken();
        int n=sc.nextInt();
        int k=sc.nextInt();
        int ar[]=new int[n];
        for(int x=0;x<n;x++)
        {
            ar[x]=sc.nextInt();
        }
        Arrays.parallelSort(ar);
        int sum=0;
        for(int x=0;x<k;x++)
        {
            sum+=ar[x];
        }
        out.println(sum);
        out.close();
    } main {
        Kioken sc = new Kioken();
        int n=sc.nextInt();
        int k=sc.nextInt();
        int ar[]=new int[n];
        for(int x=0;x<n;x++)
        {
            ar[x]=sc.nextInt();
        }
        Arrays.parallelSort(ar);
        int sum=0;
        for(int x=0;x<k;x++)
        {
            sum+=ar[x];
        }
        out.println(sum);
        out.close();
    } Kioken sc = new Kioken(); sc new Kioken() int n=sc.nextInt(); n sc.nextInt() sc.nextInt sc int k=sc.nextInt(); k sc.nextInt() sc.nextInt sc int ar[]=new int[n]; ar new int[n] n for(int x=0;x<n;x++)
        {
            ar[x]=sc.nextInt();
        } int x=0; int x=0; x 0 x<n x n x++ x++ x {
            ar[x]=sc.nextInt();
        } {
            ar[x]=sc.nextInt();
        } ar[x]=sc.nextInt() ar[x] ar x sc.nextInt() sc.nextInt sc Arrays.parallelSort(ar) Arrays.parallelSort Arrays ar int sum=0; sum 0 for(int x=0;x<k;x++)
        {
            sum+=ar[x];
        } int x=0; int x=0; x 0 x<k x k x++ x++ x {
            sum+=ar[x];
        } {
            sum+=ar[x];
        } sum+=ar[x] sum ar[x] ar x out.println(sum) out.println out sum out.close() out.close out String args[] args public static void kamehameha()
    {
    } kamehameha {
    } static class Kioken
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        public String next()
        {
            while (!st.hasMoreTokens())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        public String nextLine()
        {
            try
            {
                return br.readLine();
            } catch (Exception e)
            {
                e.printStackTrace();
            }
            return null;
        }

        public boolean hasNext()
        {
            String next = null;
            try
            {
                next = br.readLine();
            } catch (Exception e)
            {
            }
            if (next == null)
            {
                return false;
            }
            st = new StringTokenizer(next);
            return true;
        }
    } Kioken BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) StringTokenizer st = new StringTokenizer(""); st new StringTokenizer("") public String next()
        {
            while (!st.hasMoreTokens())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        } next {
            while (!st.hasMoreTokens())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        } while (!st.hasMoreTokens())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e)
                {
                    e.printStackTrace();
                }
            } !st.hasMoreTokens() st.hasMoreTokens() st.hasMoreTokens st {
                try
                {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e)
                {
                    e.printStackTrace();
                }
            } try
                {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e)
                {
                    e.printStackTrace();
                } catch (Exception e)
                {
                    e.printStackTrace();
                } Exception 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 public int nextInt()
        {
            return Integer.parseInt(next());
        } nextInt {
            return Integer.parseInt(next());
        } return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next public long nextLong()
        {
            return Long.parseLong(next());
        } nextLong {
            return Long.parseLong(next());
        } return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next public double nextDouble()
        {
            return Double.parseDouble(next());
        } nextDouble {
            return Double.parseDouble(next());
        } return Double.parseDouble(next()); Double.parseDouble(next()) Double.parseDouble Double next() next public String nextLine()
        {
            try
            {
                return br.readLine();
            } catch (Exception e)
            {
                e.printStackTrace();
            }
            return null;
        } nextLine {
            try
            {
                return br.readLine();
            } catch (Exception e)
            {
                e.printStackTrace();
            }
            return null;
        } try
            {
                return br.readLine();
            } catch (Exception e)
            {
                e.printStackTrace();
            } catch (Exception e)
            {
                e.printStackTrace();
            } Exception e {
                e.printStackTrace();
            } e.printStackTrace() e.printStackTrace e {
                return br.readLine();
            } return br.readLine(); br.readLine() br.readLine br return null; null public boolean hasNext()
        {
            String next = null;
            try
            {
                next = br.readLine();
            } catch (Exception e)
            {
            }
            if (next == null)
            {
                return false;
            }
            st = new StringTokenizer(next);
            return true;
        } hasNext {
            String next = null;
            try
            {
                next = br.readLine();
            } catch (Exception e)
            {
            }
            if (next == null)
            {
                return false;
            }
            st = new StringTokenizer(next);
            return true;
        } String next = null; next null try
            {
                next = br.readLine();
            } catch (Exception e)
            {
            } catch (Exception e)
            {
            } Exception e {
            } {
                next = br.readLine();
            } next = br.readLine() next br.readLine() br.readLine br if (next == null)
            {
                return false;
            } next == null next null {
                return false;
            } return false; false st = new StringTokenizer(next) st new StringTokenizer(next) return true; true public class Main
{
    static PrintWriter out = new PrintWriter((System.out));

    public static void main(String args[]) throws IOException
    {
        Kioken sc = new Kioken();
        int n=sc.nextInt();
        int k=sc.nextInt();
        int ar[]=new int[n];
        for(int x=0;x<n;x++)
        {
            ar[x]=sc.nextInt();
        }
        Arrays.parallelSort(ar);
        int sum=0;
        for(int x=0;x<k;x++)
        {
            sum+=ar[x];
        }
        out.println(sum);
        out.close();
    }

    public static void kamehameha()
    {
    }

    static class Kioken
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        public String next()
        {
            while (!st.hasMoreTokens())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        public String nextLine()
        {
            try
            {
                return br.readLine();
            } catch (Exception e)
            {
                e.printStackTrace();
            }
            return null;
        }

        public boolean hasNext()
        {
            String next = null;
            try
            {
                next = br.readLine();
            } catch (Exception e)
            {
            }
            if (next == null)
            {
                return false;
            }
            st = new StringTokenizer(next);
            return true;
        }
    }
} public class Main
{
    static PrintWriter out = new PrintWriter((System.out));

    public static void main(String args[]) throws IOException
    {
        Kioken sc = new Kioken();
        int n=sc.nextInt();
        int k=sc.nextInt();
        int ar[]=new int[n];
        for(int x=0;x<n;x++)
        {
            ar[x]=sc.nextInt();
        }
        Arrays.parallelSort(ar);
        int sum=0;
        for(int x=0;x<k;x++)
        {
            sum+=ar[x];
        }
        out.println(sum);
        out.close();
    }

    public static void kamehameha()
    {
    }

    static class Kioken
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        public String next()
        {
            while (!st.hasMoreTokens())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        public String nextLine()
        {
            try
            {
                return br.readLine();
            } catch (Exception e)
            {
                e.printStackTrace();
            }
            return null;
        }

        public boolean hasNext()
        {
            String next = null;
            try
            {
                next = br.readLine();
            } catch (Exception e)
            {
            }
            if (next == null)
            {
                return false;
            }
            st = new StringTokenizer(next);
            return true;
        }
    }
} Main
/*
    Author: @__goku__
            ssrivastava990@gmail.com
 
                   `\-.   `
                      \ `.  `
                       \  \ |
              __.._    |   \.       S O N - G O K U
       ..---~~     ~ . |    Y
         ~-.          `|    |
            `.               `~~--.
              \                    ~.
               \                     \__. . -- -  .
         .-~~~~~      ,    ,            ~~~~~~---...._
      .-~___        ,'/  ,'/ ,'\          __...---~~~
            ~-.    /._\_( ,(/_. 7,-.    ~~---...__
           _...>-  P""6=`_/"6"~   6)    ___...--~~~
            ~~--._ \`--') `---'   9'  _..--~~~
                  ~\ ~~/_  ~~~   /`-.--~~
                    `.  ---    .'   \_
                      `. " _.-'     | ~-.,-------._
                  ..._../~~   ./       .-'    .-~~~-.
            ,--~~~ ,'...\` _./.----~~.'/    /'       `-
        _.-(      |\    `/~ _____..-' /    /      _.-~~`.
       /   |     /. ^---~~~~       ' /    /     ,'  ~.   \
      (    /    (  .           _ ' /'    /    ,/      \   )
      (`. |     `\   - - - - ~   /'      (   /         .  |
       \.\|       \            /'        \  |`.           /
       /.'\\      `\         /'           ~-\         .  /\
      /,   (        `\     /'                `.___..-      \
     | |    \         `\_/'                  //      \.     |
     | |     |                 _Seal_      /' |       |     |
 */

import java.io.*;
import java.util.*;

public class Main
{
    static PrintWriter out = new PrintWriter((System.out));

    public static void main(String args[]) throws IOException
    {
        Kioken sc = new Kioken();
        int n=sc.nextInt();
        int k=sc.nextInt();
        int ar[]=new int[n];
        for(int x=0;x<n;x++)
        {
            ar[x]=sc.nextInt();
        }
        Arrays.parallelSort(ar);
        int sum=0;
        for(int x=0;x<k;x++)
        {
            sum+=ar[x];
        }
        out.println(sum);
        out.close();
    }

    public static void kamehameha()
    {
    }

    static class Kioken
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        public String next()
        {
            while (!st.hasMoreTokens())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        public String nextLine()
        {
            try
            {
                return br.readLine();
            } catch (Exception e)
            {
                e.printStackTrace();
            }
            return null;
        }

        public boolean hasNext()
        {
            String next = null;
            try
            {
                next = br.readLine();
            } catch (Exception e)
            {
            }
            if (next == null)
            {
                return false;
            }
            st = new StringTokenizer(next);
            return true;
        }
    }
}