n,m=gets.split().map!{|i|i.to_i}
a=gets.split().map!{|i|i.to_i}
a.slice!(n..a.length)
a.sort
max=0
n.times do |i|
  (i+1).times do |j|
    if a[i]+a[j]<=m then
      max=a[i]+a[j]
    end
  end
end
print max
