import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [n,a,b,c] <- getIntList
    ls <- replicateM n getInt
    let zs = map (\g -> zip g ls) gs
            where gs = sequence $ replicate n [0..3]
    let ans = minimum $ map (solve a b c) zs
    print ans

solve a b c z | check = m1 + m2 + m3 + g1 + g2 + g3
              | otherwise = 100000
    where s1 = map snd $ filter ((==1).fst) z
          s2 = map snd $ filter ((==2).fst) z
          s3 = map snd $ filter ((==3).fst) z
          m1 = (10 *) $ (length s1) - 1
          m2 = (10 *) $ (length s2) - 1
          m3 = (10 *) $ (length s3) - 1
          g1 = abs $ a - (sum s1)
          g2 = abs $ b - (sum s2)
          g3 = abs $ c - (sum s3)
          check = all (not . null) [s1,s2,s3]