using System;
using System.Linq;
using System.Collections.Generic;

namespace cs
{
    class Program
    {
        static void Main(string[] args)
        {
            var pg = new Program();
            //pg.Test();
            pg.Execute();

        }
        private void Test()
        {
            OutputResult(0);
            OutputResult(1);
            OutputResult(2);
            OutputResult(4);
        }
        
        private void Execute()
        {
            var (N, K) = ReadLinesTuple2<int>();
            var input = ReadLinesList<int>();
         
            OutputResult(input.OrderBy(e => e).Take(K).Sum());
            
        }


        private void OutputResult<T>(T result)
        {
            Console.WriteLine(result);
        }

        private void OutputList<TItem, TList>(TList result)
            where TList : IEnumerable<TItem>
        {
            result.ToList().ForEach(e => Console.WriteLine(e));
        }

        private static T ReadLine<T>()
        {
            return (T)Convert.ChangeType(Console.ReadLine(), typeof(T));
        }
        private static IEnumerable<T> ReadLinesList<T>()
        {
            return Console.ReadLine().Split(' ').Select(i => (T)Convert.ChangeType(i, typeof(T)));
        }

        public static (T, T) ReadLinesTuple2<T>()
        {
            var input = Console.ReadLine().Split(' ');
            return ((T)Convert.ChangeType(input.ElementAt(0), typeof(T)), (T)Convert.ChangeType(input.ElementAt(1), typeof(T)));
        }
        public static (T, T, T) ReadLinesTuple3<T>()
        {
            var input = Console.ReadLine().Split(' ');
            return ((T)Convert.ChangeType(input.ElementAt(0), typeof(T)), (T)Convert.ChangeType(input.ElementAt(1), typeof(T)), (T)Convert.ChangeType(input.ElementAt(2), typeof(T)));
        }
        public static (T, T, T, T) ReadLinesTuple4<T>()
        {
            var input = Console.ReadLine().Split(' ');
            return ((T)Convert.ChangeType(input.ElementAt(0), typeof(T)), (T)Convert.ChangeType(input.ElementAt(1), typeof(T)), (T)Convert.ChangeType(input.ElementAt(2), typeof(T)), (T)Convert.ChangeType(input.ElementAt(3), typeof(T)));
        }
        public static IEnumerable<T> ReadLineNTimes<T>()
        {
            var input = new List<T>();
            var N = long.Parse(Console.ReadLine());
            for (int i = 0; i < N; i++)
            {
                input.Add((T)Convert.ChangeType(Console.ReadLine(), typeof(T)));
            }
            return input;
        }
        public static IEnumerable<T> ReadLineNTimes<T>(long N)
        {
            var input = new List<T>();
            for (int i = 0; i < N; i++)
            {
                input.Add((T)Convert.ChangeType(Console.ReadLine(), typeof(T)));
            }
            return input;
        }
        public static IEnumerable<T> ReadLineNTimes<T>(int N)
        {
            var input = new List<T>();
            for (int i = 0; i < N; i++)
            {
                input.Add((T)Convert.ChangeType(Console.ReadLine(), typeof(T)));
            }
            return input;
        }

        private int SolveDynamicProgramming(int n, IEnumerable<int> valueList)
        {
            var inputList = valueList.ToList();
            var dpList = new List<int>() { 0 };
            for (int i = 0; i < n; ++i)
            {
                dpList.Add(Math.Max(dpList[i], dpList[i] + inputList[i]));
            }

            return dpList[n];
        }

        private int SolveDynamicProgrammingForKnapsack(int n, int weight, List<int> valueList, List<int> weightList)
        {
            var dpList = new List<List<int>>();

            for (int i = 0; i < n + 1; ++i)
            {
                dpList.Add(Enumerable.Repeat(0, weight + 1).ToList());
            }

            for (int i = 0; i < n; ++i)
            {
                for (int w = 0; w <= weight; ++w)
                {
                    if (w >= weightList[i])
                    {
                        dpList[i + 1][w] = Math.Max(dpList[i][w - weightList[i]] + valueList[i], dpList[i][w]);
                    }
                    else
                    {
                        dpList[i + 1][w] = dpList[i][w];
                    }
                }
            }

            return dpList[n][weight];
        }

        public static int Gcd(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }

        public static IEnumerable<bool[]> BitFullSearch(int n)
        {
            if (n <= 0)
            {
                yield return new bool[] { };
                yield break;
            }

            for (int i = 0; i < Math.Pow(2, n); i++)
            {
                var array = new bool[n];
                for (int j = 0; j < n; j++)
                {
                    var targetBit = (i >> j) & 1;
                    if (targetBit == 1) array[j] = true;
                }

                yield return array;
            }
        }

    }
}


Measured memory_bytes: 28832