import Control.Monad

mymin :: [Int] -> Int
mymin (x:[]) = x
mymin (x:xs) =
  min x $ mymin xs


dfs :: [Int] -> [Int] -> [Int] -> Int
dfs [as, bs ,cs] [a, b, c] (l:ls) =
  let 
    r0 = dfs [as, bs, cs] [a, b, c] ls
    r1 = dfs [as + l, bs, cs] [a, b, c] ls + 10
    r2 = dfs [as, bs + l, cs] [a, b, c] ls + 10
    r3 = dfs [as, bs, cs + l] [a, b, c] ls + 10
  in 
    mymin [r0, r1, r2, r3]

dfs [as, bs, cs] [a, b, c] [] =
  if mymin [as, bs, cs] > 0 then
    abs(as - a) + abs(b - bs) + abs(c - cs) - 30
  else
    100000000


main = do
  [n, a, b, c] <- (map read) . words <$> getLine
  ls <- replicateM n (read <$> getLine)
  putStrLn $ show $ dfs (replicate 3 0) [a, b, c] ls
