main = do
  [_,a,b,c] <- map read . words <$> getLine
  ls        <- map read . lines <$> getContents
  print $ solve ls a b c 0 0 0

solve [] a b c a' b' c'	-- remainings, A,B,C, to make A, to make B, to make C
  | a'>0 && b'>0 && c'>0 = sum (map abs [a'-a, b'-b, c'-c]) - 30
  | otherwise            = 3000 -- greater than cost of 1,1,1 -> 1000,1000,1000
solve (x:xs) a b c a' b' c'
  = minimum [ solve xs a b c a' b' c' 			-- do not use next
            , solve xs a b c (a'+x) b' c' + 10	-- use next to make A
            , solve xs a b c a' (b'+x) c' + 10	-- use next to make B
            , solve xs a b c a' b' (c'+x) + 10 ]-- use next to make C