main = do
    n:a:b:c:_ <- (map read).words <$> getLine
    ls <- (map read).words <$> getContents
    print $ z a b c $ cmb ls

cmb [] = [((0, -10), (0, -10), (0, -10))]
cmb (l:ls) = concat [[(j l a, b, c), (a, j l b, c), (a, b, j l c), (a, b, c)] | (a, b, c) <- cmb ls]
j l (x, s) = (x+l, s+10)

z a b c xs = minimum [abs (a-u) + abs (b-v) + abs (c-w)  + h+i+j| ((u, h), (v, i), (w, j)) <- xs, u/=0, v/=0, w/=0]