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

$as.sort!

$as_expand = Array.new(10**5, 0)
$as.each{ |a|
	$as_expand[a] += 1
}

$sum_tail = Array.new(10**5 + 1, 0)
$count_tail = Array.new(10**5 + 1, 0)

(10**5 - 1).downto(0){ |i|
	if $as_expand[i] != 0 then
		$count_tail[i] = $count_tail[i + 1] + $as_expand[i]
		$sum_tail[i] = $sum_tail[i + 1] + i * $as_expand[i]
	else
		$count_tail[i] = $count_tail[i + 1] 
		$sum_tail[i] = $sum_tail[i + 1]
	end
}

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

def calc(x, is_pruned)
	count = 0

	$as.each_with_index{ |a,i|
		if x > a then
			count += $count_tail[x - a]
		else
			count += $n
		end
		
		# 探索中はM以上になったら即打ち切り
		if is_pruned && count >= $m then
			break
		end
	}

	count
end

def calc_sum(x)
	sum = 0

	$as.each_with_index{ |a, i|
		if x > a then
			sum += $sum_tail[x - a] + a * $count_tail[x - a]
		else
			sum += $sum_tail[0] + a * $n
		end
	}

	sum
end


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

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

	current = (min + max) / 2
end

# 取り直し
result = calc(current, false)

score = calc_sum(current)

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

puts score
