N, M = gets.split.map(&:to_i)
As = gets.split.map(&:to_i)

as = As.sort.reverse
lb, ub = 2*as.last, 2*as.first
gs = as.each_with_object(Array.new(ub + 1, 0)){|a, ary| ary[a] += 1}
ub.downto(1){|i| gs[i - 1] += gs[i]}
g = ->(x){x > 0 ? gs[x] : N}
d = ub.downto(lb).to_a.bsearch{|x| as.inject(0){|s, a| s + g[x - a]} >= M}
ca = as.inject([0]){|ary, a| ary << ary.last + a}
res, m = 0, M
as.map{|a| [a, g[d - a]]}.reject{|a, n| n.zero?}.each do |a, n|
  res += a*n + ca[n]
  m -= n
end
puts res + d*m