N,M = gets.split(' ').map(&:to_i)
#n,k=gets.split(' ').map(&:to_i)
A=gets.split(' ').map(&:to_i).sort
#tajigen = Array.new(4) { Array.new(2,0) }
#maze = h.times.map { gets.chomp }
A_min = A[0]
A_max = A.last

$a_cnt = Array.new(A_max+1,0)

A.each do |i|
  $a_cnt[i] += 1
end

for i in 1..A_max
  $a_cnt[i] += $a_cnt[i-1]
end

cnt = 0
def countup(mid)
  cnt = 0
  A.each do |i|
    put = mid-i
    if put >= A_max
      next
    elsif put < A_min
      cnt += N
    else
      cnt += N-$a_cnt[put]
    end
    break if cnt > M
  end
  return cnt
end

min = A_min - 1
max = A_max * 2 + 1

while (max-min)!=1
  mid = (max+min)/2
  if countup(mid)>=M
    min=mid
  else
    max=mid
  end
end
#puts max

A_rui = Array.new(N+1,0)
for i in 0..N-1
  A_rui[i+1] = A_rui[i] + A[N-1-i]
end
#puts A_rui

ans = 0
a_count = 0

for i in 0..N-1
  x=max-A[i]
  if x<=A_min
    ans += A[i] * N + A_rui[N]
    a_count += N
  elsif x>A_max
    next
  else
    t = N - $a_cnt[x-1]
    ans += A_rui[t] + A[i]*t
    a_count += t
  end
end

ans -= (a_count-M)*max if a_count > M
puts ans
