N, M = gets.chomp.split(" ").map(&:to_i)
A = gets.chomp.split(" ").map(&:to_i)

A.sort!
wk = 0
B = []
(N - 1).downto(0){|i|
  wk += A[i]
  B.unshift(wk)
}

def sum(x)
  ret = 0
  (N - 1).downto(0){|i|
    r = A.bsearch_index{|a| x - A[i] <= a}
    break if r.nil?
    ret += B[r] + (N - r) * A[i]
  }
  ret
end

def count_over(x)
  ret = 0
  (N - 1).downto(0){|i|
    r = A.bsearch_index{|a| x - A[i] <= a}
    break if r.nil?
    ret += (N - r)
  }
  ret
end

def bin_search(i)
   h, l = [2 * A[-1], 0]
  while(h - l > 1) do
    m = (h - l) / 2 + l
    (count_over(m) > i) ? l = m : h = m
  end
  return [l, h]
end

h, l = bin_search(M)
hh = count_over(h)
if hh == M then
  ans = sum(h)
else
  ans = sum(l)
  ll = count_over(l)
  ans += ((M - ll) * h) if ll != M
end

puts ans
