N,M = gets.split(" ").map(&:to_i)
A = gets.chomp.split(" ").map(&:to_i).sort.reverse
@sumA = [0]
A.each_with_index do |a,i|
  @sumA[i+1] = @sumA[i] + A[i]
end
@sumA.shift

def 点以上取れるパターン数 x
  count = 0
  N.times do |i|
    point = x - A[i]
    if A[0] >= point
      left = 0
      right = N
      while(left+1<right) do
        a = (left + right) >>1
        if A[a] >= point 
          left = a
        else
          right = a
        end
      end
      count += left + 1
    end
    # puts "#{A[i]} #{point} #{c}"
  end
  count
end

left = 0
right = A[0]*2 + 1
while(left+1<right) do
  x = (left + right) >>1
  m = 点以上取れるパターン数(x)
  # p [x, m]
  if m >= M
    left = x
  else
    right = x
  end
end
x = left
result = 0
m = 0
N.times do |i|
  break if m >= M
  N.times do |j|
    break if m >= M
    if A[i] + A[j] >= x
      result += A[i] + A[j]
      m += 1
    else
      break
    end
  end
end
# p x
# p [M, m]
puts result