N, M = gets.split.map(&:to_i)
As = gets.split.map(&:to_i).sort
As_max = As.last
As_min = As.first

$rui = Array.new(N + 1, 0)
N.times do |i|
  $rui[i+1] += $rui[i] + As[i]
end

$rui_cnt = Array.new(As_max + 1, 0)
As.each do |n|
  $rui_cnt[n] += 1
end
As_max.times do |i|
  $rui_cnt[i+1] += $rui_cnt[i]
end

def f(x)
  cnt = 0
  N.times do |i|
    t = x - As[i]
    if t > As_max
      next
    elsif t < As_min
      cnt += N
    else
      cnt += N - $rui_cnt[t-1]
    end
  end
  cnt
end

def g(x)
  cnt = 0
  tot = 0
  N.times do |i|
    t = x - As[i]
    if t > As_max
      next
    elsif t < As_min
      cnt += N
      tot += $rui[N] + As[i] * N
    else
      aa = N - $rui_cnt[t-1]
      cnt += aa
      tot += $rui[N] - $rui[$rui_cnt[t-1]] + As[i] * aa
    end
  end
  tot -= (cnt - M) * x if cnt > M
  tot
end

max = 2 * 10 ** 5 + 1
min = 0
while min + 1 < max
  mid = (max + min) / 2
  if f(mid) >= M
    min = mid
  else
    max = mid
  end
end

puts g(min)