using System;
using System.Collections.Generic;

public class Program
{
	public static void Main(String[] args) {
        	int a = Convert.ToInt32(Console.ReadLine());
          	int noOfItems = Convert.ToInt32(Console.ReadLine());
          	var mylst = new List<int>();
          	for(int i = 0; i < a; ++i) {
            	mylst.Add(Convert.ToInt32(Console.ReadLine()));
            }
            mylst.Sort();
            int ctr = 0, sum = 0;
            foreach(var item in mylst) {
            	if(ctr < noOfItems)
                	sum += item;
                else
                	break;
                ctr++;
            }
            Console.WriteLine(sum);
        }
}