module Main where

import Data.List
import Control.Monad
import Debug.Trace

readLs :: Read a => IO [a]
readLs = fmap read . words <$> getLine

readTuple :: Read a  => IO (a, a)
readTuple = do
    [f, s] <- readLs
    pure (f, s)

solve :: Int -> Int -> Int -> [Int] -> Int
solve a b c lss = inner [] [] [] lss where
    inner :: [Int] -> [Int] -> [Int] -> [Int] -> Int
    inner [] b' c' [] = 100000000
    inner a' [] c' [] = 100000000
    inner a' b' [] [] = 100000000
    inner a' b' c' [] = abs (a - sum a') + abs (b - sum b') + abs (c - sum c')
        + (max 0 $ length a' - 1) * 10
        + (max 0 $ length b' - 1) * 10
        + (max 0 $ length c' - 1) * 10
    inner a' b' c' (l:ls) = minimum [ inner (l:a') b' c' ls 
                                       , inner a' (l: b') c' ls 
                                       , inner a'  b' (l: c') ls 
                                       , inner a'  b' c' ls 
                                        ]  


main = do
    [n,a,b,c] <- readLs
    ls <- replicateM n readLn
    print $ solve a b c ls 
