class HeapArray
  def initialize
    @heapArr = []
  end

  def push(n)
    i = @heapArr.size

    while i>0
      p = (i-1)/2
      break if @heapArr[p] <= n
      @heapArr[i] = @heapArr[p]
      i=p
    end

    @heapArr[i] = n
  end

  def pop
    min = @heapArr[0]
    n   = @heapArr.pop
    unless @heapArr.empty?
      i   = 0
      while (i*2+1) < @heapArr.size
        if @heapArr[i*2+2].nil?
          buf=i*2+1
        else
          buf=(@heapArr[i*2+1]<@heapArr[i*2+2])?i*2+1:i*2+2
        end
        break if @heapArr[buf] >= n
        @heapArr[i] = @heapArr[buf]
        i=buf
      end
      @heapArr[i]=n
    end
    return min
  end
end


ha = HeapArray.new

io = STDIN
n,m=io.gets.split.map(&:to_i)
a=io.gets.split.map(&:to_i)
a.each{|i|ha.push(-i*2)}
n.times do |i|
  (i+1...n).each do |j|
    ha.push(-(a[i]+a[j]))
    ha.push(-(a[i]+a[j]))
  end
end
puts m.times.map{-ha.pop}.inject(:+)
