module Main where

import Control.Monad
import qualified Data.Set as S
import qualified Data.IntSet as I

data D = D I.IntSet Int Int -- indeces, length, additinal cost
  deriving Eq

instance Ord D where
  D _ l _ <= D _ l' _ = l <= l'

main :: IO ()
main = do
  [n, a, b, c] <- map read . words <$> getLine :: IO [Int]
  ls <- replicateM n $ read <$> getLine :: IO [Int]
  print $ go (initSet ls) [c, b, a] 0
    where
      initSet ls = S.fromList [ (\(is, ls') -> 
        D (I.fromList is) (sum ls') ((length ls' - 1) * 10)) $ unzip ts 
        | ts <- concatMap (comb5 $ zip [1..] ls) [1..length ls] ]
      go _ [] currentCost = currentCost
      go set (obj:objs) currentCost = 
        let 
          (d, cost) = getMinimum set obj 
          newSet = filterD d set
          newCost = currentCost + cost
        in go newSet objs newCost
        where
          getMinimum :: S.Set D -> Int -> (D, Int)
          getMinimum set obj = 
            let d@(D is l c) = S.findMin $ S.map (f obj) set
            in (d, l + c)
            where
              f obj (D is l c) = D is (abs (l - obj)) c
          filterD :: D -> S.Set D -> S.Set D
          filterD (D is _ _) set = 
            S.filter (\(D is' _ _) -> not $ is `I.isSubsetOf` is') set

comb5 :: [a] -> Int -> [[a]]
comb5 [] _ = [[]]
comb5 ns size = comb' size [(ns, [])]
    where
      comb' 0 xs = [a | (_, a) <- xs]
      comb' c xs = comb' (c - 1) $ concatMap comb'' xs
      comb'' (x : xs, ys) = (xs, ys ++ [x]) : comb'' (xs, ys)
      comb'' _ = []