class Array
  def cumsum; s = 0; map{|k| s += k } end
end

n, m = gets.to_s.split.map{|t|t.to_i}
a    = gets.to_s.split.map{|t|t.to_i}.sort

sum_min = a[0]  * 2
sum_max = a[-1] * 2

sum_x = (sum_min .. sum_max).bsearch do |sum_x|
  cnt = 0
  a.each{ |r| cnt += n - (a.bsearch_index{|l| sum_x <= l + r } || n) }
  cnt <= m
end

c = (a.unshift(0)).cumsum
s = c[-1]

ans = 0
a.each do |r|
  
  pos = a.bsearch_index{|l| l + r >= sum_x } || n 
  cnt = n - pos
  ans += cnt * r + (s - c[pos])
  m -= cnt
end

ans += m * sum_x

puts ans
