import Control.Monad

solve :: [Int] -> (Int, Int, Int) -> (Int, Int, Int) -> Int
solve [] (a,b,c) (x,y,z)
    | a `min` b `min` c == 0 = 10^9+7
    | otherwise = (abs $ a-x) + (abs $ b-y) + (abs $ c-z) - 30
solve (l:ls) (a,b,c) (x,y,z) = s1 `min` s2 `min` s3 `min` s4
    where
        s1 = (solve ls (a,b,c) (x,y,z))
        s2 = (solve ls (a+l,b,c) (x,y,z)) + 10
        s3 = (solve ls (a,b+l,c) (x,y,z)) + 10
        s4 = (solve ls (a,b,c+l) (x,y,z)) + 10

main = do 
    [n,a,b,c] <- map read . words <$> getLine :: IO [Int]
    xs <- replicateM n readLn :: IO [Int]
    print $ solve xs (0,0,0) (a,b,c)