module Main where
import Control.Monad
import Control.Applicative
import Data.Maybe
import Data.List
import qualified Text.Printf
import qualified Data.ByteString.Char8 as BC
import qualified Data.ByteString as BC

import           Data.Array.Unboxed (UArray, (!))
import qualified Data.Array.Unboxed as Array

------------------------------------------

main :: IO ()
main = do
  [n, m] <- readInts
  if n == m && m == 0 then return ()
  else do
  arr <- Array.listArray (0, n) <$> (0:) <$> replicateM n readInt :: IO (UArray Int Int)

  let len = (n+1)^2
      arr2 :: UArray Int Int
      arr2 = Array.listArray (0, len-1) $ sort [arr ! x + arr ! y | x <- [0..n], y <- [0..n]]
      go l r cand
        | l == len-1 && r == len-1 = next
        | r == len-1               = go (l+1) r next
        | rInc                     = go l (r+1) next
        | otherwise                = if l < r then go (l+1) r next else next
        where cand' = arr2 ! l + arr2 ! r
              next = if cand' <= m then max cand cand' else cand
              rInc = r+1 < len && arr2 ! l + arr2 ! (r+1) <= m
  print $ go 0 0 0
  main


------------------------------------------

{- Int input -}

parseInt :: BC.ByteString -> Int
parseInt = fst . fromJust . BC.readInt

parseInts :: BC.ByteString -> [Int]
parseInts = map parseInt <$> BC.words

readInt :: IO Int
readInt = parseInt <$> BC.getLine

readInts :: IO [Int]
readInts = parseInts <$> BC.getLine

{- Double Formatting -}

doubleFmt :: Double -> String
doubleFmt = Text.Printf.printf "%.12f"