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

namespace ConsoleApp2
{
    class Program
    {
        static void Main()
        {
            int z = 9999;
            var a = Console.ReadLine().Split(' ');
            var b = Console.ReadLine().Split(' ');

            Array.Sort(b);
            int ans = 0;
            for (int j = 0; j < int.Parse(a[1]); j++)
            {
                ans += int.Parse(b[j]);
            }

            Console.WriteLine(ans);
        }
    }
}