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

class Program
{
    static void Main(string[] args)
    {
        var nk = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        var n = nk[0];
        var k = nk[1];
        var p = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

        p = p.OrderBy(t => t).ToArray();
        var mins = p.Take(3).ToArray();

        Console.WriteLine(mins.Sum());
    }
}
