using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
public class B
{
    static void Main()
    {
        string[] word = ReadLine().Split(' ');
        int n = int.Parse(word[0]);
        int k = int.Parse(word[1]);
        int[] p = new int[n];
        int[] r = new int[k];
        for (int x = 0; x < n; x++)
        {
            p[n] = int.Parse(word[n + 2]);
        }
        Array.Sort(p);
        Array.Copy(p, r, k);
        WriteLine(r.Sum());
    }
}