import Data.List ((\\))

main :: IO ()
main = do
  nabc <- map read . words <$> getLine
  ls <- map read . lines <$> getContents
  let
    patterns = filter (null . ([1, 2, 3] \\)) . sequence . replicate (nabc !! 0) $ [0, 1, 2, 3]
    m = minimum . map mp $ patterns
    mp pattern = sum . flip map [1, 2, 3] . (\pls i -> let lsi = map snd . filter ((==  i) . fst) $ pls in (10 * (length lsi - 1) + abs (sum lsi - (nabc !! i)))) . zip pattern $ ls
  print m
