using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder_171B
{
    class Program
    {
        static void Main(string[] args)
        {
            var sum = Console.ReadLine();
            var price = Console.ReadLine();
 
            var productsum = sum.Split(' ').Select(s => int.Parse(s)).ToArray();
            var productprice = price.Split(' ').Select(t => int.Parse(t)).ToArray();

            //var productprice = new List<int> ();

            Array.Sort(productprice);

           //foreach (var i in productprice)            {
                //Console.WriteLine(i);
            //}

            int cost = 0;

            for( int j= 0;j<productsum[1]; ++j)
            {
                 cost = cost + productprice[j];
            }

            Console.WriteLine(cost);

            Console.ReadKey();

        }
    }
}