import Control.Monad.State
import Data.List
import Control.Monad

main = do
    [n,a,b,c] <- map read . words <$> getLine :: IO [Int]
    ls <- join <$> replicateM n (map read . words <$> getLine) :: IO [Int]
    print .fst $ runState (solve (n-2) [a,b,c]) [ls]  

reflesh :: Int -> [Int] -> State [[Int]] Int 
reflesh n ts = state $ \s -> 
    let merge = \p ps -> (sum p):(myDel p ps) 
        -- s' = map (\xs -> [merge x | x <- comb 2 xs]) s
        s' = s >>= (\xs -> [merge x xs| x <- comb 2 xs])
        a' = (minimum $ map (cand2Scr ts) s) + 10*n
    in (a',s')

solve :: Int -> [Int] -> State [[Int]] Int 
solve 0 ts = do
    reflesh 0 ts
solve n ts = do
    a' <- solve (n-1) ts
    a <- reflesh n ts
    return (min a a')

cand2Scr :: [Int] -> [Int] -> Int
cand2Scr ts ps = minimum [ sum . map abs $ zipWith (-) p ts | p <- permutations ps] 

comb :: Int -> [a] -> [[a]]
comb 0 xs = [[]]
comb _ [] = []
comb n (x:xs) = [x:y | y <- comb (n-1) xs] ++ comb n xs

myDel :: [Int] -> [Int] -> [Int]
myDel [] ls = ls
myDel (p:ps) ls = myDel ps (Data.List.delete p ls)