N, M = gets.split.map(&:to_i)
A = gets.split.map(&:to_i).sort.reverse
MAX_V = A.max

RUI = [0]
COUNTER = Array.new(MAX_V + 1, 0)

A.each do |a|
  COUNTER[a] += 1
  RUI << RUI.last + a
end

(MAX_V - 1).downto(0) do |i|
  COUNTER[i] = COUNTER[i] + COUNTER[i + 1]
end

def f(x)
  cnt = 0

  A.each do |a|
    t = x - a

    next if MAX_V < t

    if t <= 0
      cnt += N
    else
      cnt += COUNTER[t]
    end
  end

  cnt
end

ok = 0
ng = MAX_V * 2 + 1

while (ok - ng).abs > 1
  mid = (ok + ng) / 2

  if f(mid) >= M
    ok = mid
  else
    ng = mid
  end
end

ans = 0

A.each do |a|
  t = [0, ok - a].max

  cnt = COUNTER[t] || 0

  next if cnt <= 0

  ans += RUI[cnt] + (a * cnt)
end

ans -= (f(ok) - M) * ok

puts ans
