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 $ foldl (\x y -> min x $ solve ls y [a,b,c] + y*10) (maxBound :: Int) [0..n-3]

solve :: [Int] -> Int -> [Int] -> Int 
solve ls i ts = minimum . map (\x -> minimum $ cand2Scr x ts) $ makeCand i ls

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

makeCand :: Int -> [Int] -> [[Int]]
makeCand 0 ls = [ls]
makeCand n ls = join [ makeCand (n-1) $ merge p | p <- ps ]
    where
        ps = comb 2 ls
        merge = \p -> (sum p):(myDel p ls) 
        dbg = [ join . makeCand (n-1) $ merge p | p <- 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)
