io = STDIN
n,m=io.gets.split.map(&:to_i)
a=io.gets.split.map(&:to_i)
cand=a.map{|i|i*2}
n.times do |i|
  (i+1...n).each do |j|
    cand << a[i]+a[j]
    cand << a[i]+a[j]
  end
end
puts cand.sort[-m..-1].inject(:+)
