require 'pp'

n, $m = gets.split.map &:to_i
$as = gets.split.map &:to_i

$as.sort!

$sum_tail = []

sum = 0

$as.reverse.each_with_index{ |x,i|
	sum += x
	$sum_tail[$as.size - i - 1] = sum
}

# 握手による幸福度向上値をxとし、(x以上の組み合わせの数)>=mとなるxを2項探索で探す

def calc(x)
	count = 0

	$as.each{ |a|
		if x > a then
			y = x - a
			index = $as.bsearch_index{ |aa| aa >= y }
			if index != nil then
				count += $as.size - index
			end
		else
			count += $as.size
		end
	}

	count
end

def calc_sum(x)
	sum = 0

	$as.each{ |a|
		y = x - a
		index = $as.bsearch_index{ |aa| aa >= y }
		if index != nil then
			sum += $sum_tail[index] + a * ($as.size - index)
		end
	}

	sum
end


min = $as[0] * 2
max = $as[-1] * 2
current = (min + max) / 2
result = nil

while min != max 
	result = calc(current)
	
	if result >= $m then
		if current != min then
			min = current
		else
			break
		end
	else
		max = current
	end

	current = (min + max) / 2
end

if result == nil then
	result = calc(current)
end

score = calc_sum(current)

if result != $m then
	score -= current * (result - $m)
end

puts score
