
{-# LANGUAGE MultiWayIf #-}

import qualified Data.ByteString.Char8 as B
import Data.Char (isSpace)
import Data.List (unfoldr)
import Data.Bits (shiftR)

readInt = B.readInt . B.dropWhile isSpace
readInts = unfoldr readInt

inf = 10000

a#b = abs (a-b)

solv :: Int -> Int -> Int -> [Int] -> Int
solv a b c ls = go ls (0,0,0) 0 where
  go [] (la,lb,lc) cost
    | la==0 || lb==0 || lc==0 = inf
    | otherwise = cost + a#la + b#lb + c#lc
  go (l:ls) (la,lb,lc) cost = minimum [forA, forB, forC, unuse] where
    halfl = shiftR l 1
    forA = if
      | la/=0 && la#a < halfl -> inf
      | otherwise -> go ls (la+l, lb, lc) $ if la>0 then cost+10 else cost
    forB = if
      | lb/=0 && lb#b < halfl -> inf
      | otherwise -> go ls (la, lb+l, lc) $ if lb>0 then cost+10 else cost
    forC = if
      | lc/=0 && lc#c < halfl -> inf
      | otherwise -> go ls (la, lb, lc+l) $ if lc>0 then cost+10 else cost
    unuse = go ls (la,lb,lc) cost

main = do
  [n,a,b,c] <- readInts <$> B.getLine
  ls <- readInts <$> B.getContents
  print $ solv a b c ls
