local mfl = math.floor

local function comp(a, b)
  return a < b
end

local function lower_bound(ary, x)
  local num = #ary
  if num == 0 then return 1 end
  if not comp(ary[1], x) then return 1 end
  if comp(ary[num], x) then return num + 1 end
  local min, max = 1, num
  while 1 < max - min do
    local mid = mfl((min + max) / 2)
    if comp(ary[mid], x) then
      min = mid
    else
      max = mid
    end
  end
  return max
end

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

local function solve(x)
  local cnt = 0
  for i = 1, n do
    local dst = x - a[i]
    local pos = lower_bound(a, dst)
    cnt = cnt + n + 1 - pos
  end
  return m <= cnt
end

local min, max = 0, 200001
while 1 < max - min do
  local mid = mfl((max + min) / 2)
  if solve(mid) then
    min = mid
  else
    max = mid
  end
end
local ret = 0LL
local mcnt = 0
for i = 1, n do
  local dst = min - a[i]
  local pos = lower_bound(a, dst)
  if pos == 1 then
    ret = ret + asum[n] + n * a[i]
  else
    ret = ret + asum[n] - asum[pos - 1] + (n + 1 - pos) * a[i]
  end
  mcnt = mcnt + n + 1 - pos
end
if m < mcnt then
  ret = ret - (mcnt - m) * min
end
local str = tostring(ret):gsub("LL", "")
print(str)
