{-# LANGUAGE TupleSections      #-}

import Data.List
import Data.Array.Unboxed
import Data.Array.MArray
import Data.Array.ST
import Control.Monad
import Control.Monad.ST
import Debug.Trace

n_num :: Int -> Int -> [Int]
n_num n 0 = []
n_num n i = (mod i n) : (n_num n $ div i n)

mp0 :: Int -> [Int] -> Int
mp0 _ [] = 8000
mp0 n xs = (abs $ (sum xs)-n)+((length xs)-1)*10

mp :: Int -> Int -> Int -> [(Int,Int)] -> Int
mp a b c xs = sum [mpA,mpB,mpC]
   where mpA = mp0 a $ map snd (filter (\x -> fst x == 0) xs)
         mpB = mp0 b $ map snd (filter (\x -> fst x == 1) xs)
         mpC = mp0 c $ map snd (filter (\x -> fst x == 2) xs)

main :: IO ()
main = do
    [n,a,b,c] <- map read.words <$> getLine :: IO [Int]
    ls <- replicateM n $ read <$> getLine
    let n' i = (n_num 4 i) ++ (take (n-(length $ n_num 4 i)) (repeat 0))
    print $ minimum $ map (\i -> mp a b c $ zip (n' i) ls) [0..4^n-1]
