import Foundation

var type: Int = Int(readLine()!)!
var min: Int = Int(readLine()!)!
var priceList: [Int] = []

for i in 0 ..< type {
    priceList.append(Int(readLine()!)!)
}

priceList.sort {$0 < $1}

print(priceList[0] + priceList[1] + priceList[2])