
solv a b c ls = minimum $ go ls ((0,0),(0,0),(0,0))where
  go [] ((sa,la),(sb,lb),(sc,lc))
    | la==0 || lb==0 || lc==0 = []
    | otherwise = [(la+lb+lc-3)*10 + abs (a-sa) + abs (b-sb) + abs (c-sc)]
  go (x:xs) ((sa,la),(sb,lb),(sc,lc))
    = concat [ go xs ((sa+x,la+1),(sb,lb),(sc,lc))
             , go xs ((sa,la),(sb+x,lb+1),(sc,lc))
             , go xs ((sa,la),(sb,lb),(sc+x,lc+1))
             , go xs ((sa,la),(sb,lb),(sc,lc))
             ]

main = do
  [n,a,b,c] <- map read . words <$> getLine :: IO [Int]
  xs <- map read . words <$> getContents :: IO [Int]
  print $ solv a b c xs
