local n, m = io.read("*n", "*n")
local t = {}
for i = 1, n do
  t[i] = io.read("*n")
end
table.sort(t)
local tsum = {t[1]}
for i = 2, n do
  tsum[i] = tsum[i - 1] + t[i]
end

local function solve(x)
  local cnt = 0
  local pos = 1
  for i = n, 1, -1 do
    while pos <= n and t[pos] + t[i] < x do
      pos = pos + 1
    end
    if n < pos then break end
    cnt = cnt + n + 1 - pos
  end
  return m <= cnt
end

local min, max = 0, 200001
while 1 < max - min do
  local mid = (min + max) // 2
  if solve(mid) then
    min = mid
  else
    max = mid
  end
end
do
  local score = 0
  local cnt = 0
  local pos = 1
  for i = n, 1, -1 do
    while pos <= n and t[pos] + t[i] < min do
      pos = pos + 1
    end
    if n < pos then break end
    cnt = cnt + n + 1 - pos
    score = score + (n + 1 - pos) * t[i] + tsum[n]
    if 1 < pos then
      score = score - tsum[pos - 1]
    end
  end
  score = score - min * (cnt - m)
  print(score)
end
