class Array
  include Comparable
end


n, m, *a = $stdin.read.split.map(&:to_i)
a.sort!.unshift(-99999999)

q = [[a[0] * 2, 0, 0], [a[n] * 2, n, n]]
sum = 0

proc = Proc.new do |x, y|
  h = a[x] + a[y]
  w = [h, x, y]
  
  i = q.rindex { |z| z < w } + 1
  q.insert(i, w) if w != q[i]
end

m.times do
  h, x, y = q.pop
  sum += h

  proc.call(x - 1, y)
  proc.call(x, y - 1)
end

puts sum
