n, a, b, c = map(int, input().split())
ll = [int(input()) for _ in range(n)]

def dfs(cnt, x, y, z):
    if cnt == n:
        if x == 0 or y == 0 or z == 0:
            return float('INF')
        return abs(a - x) + abs(b - y) + abs(c - z) - 30
    r0 = dfs(cnt + 1, x, y, z)
    r1 = dfs(cnt + 1, x + ll[cnt], y, z) + 10
    r2 = dfs(cnt + 1, x, y + ll[cnt], z) + 10
    r3 = dfs(cnt + 1, x, y, z + ll[cnt]) + 10
    return min(r0, r1, r2, r3)

print(dfs(0, 0, 0, 0)) n, a, b, c = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split a b c int(input()) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) int(input()) int input() input ll = [int(input()) for _ in range(n)] ll [int(input()) for _ in range(n)] def dfs(cnt, x, y, z):
    if cnt == n:
        if x == 0 or y == 0 or z == 0:
            return float('INF')
        return abs(a - x) + abs(b - y) + abs(c - z) - 30
    r0 = dfs(cnt + 1, x, y, z)
    r1 = dfs(cnt + 1, x + ll[cnt], y, z) + 10
    r2 = dfs(cnt + 1, x, y + ll[cnt], z) + 10
    r3 = dfs(cnt + 1, x, y, z + ll[cnt]) + 10
    return min(r0, r1, r2, r3) dfs if cnt == n:
        if x == 0 or y == 0 or z == 0:
            return float('INF')
        return abs(a - x) + abs(b - y) + abs(c - z) - 30
     cnt == n cnt n if x == 0 or y == 0 or z == 0:
            return float('INF')
         x == 0 or y == 0 or z == 0 x == 0 or y == 0 x == 0 x 0 y == 0 y 0 z == 0 z 0 return float('INF') float('INF') float 'INF' return abs(a - x) + abs(b - y) + abs(c - z) - 30 abs(a - x) + abs(b - y) + abs(c - z) - 30 abs(a - x) + abs(b - y) + abs(c - z) abs(a - x) + abs(b - y) abs(a - x) abs a - x a x abs(b - y) abs b - y b y abs(c - z) abs c - z c z 30 r0 = dfs(cnt + 1, x, y, z) r0 dfs(cnt + 1, x, y, z) dfs cnt + 1 cnt 1 x y z r1 = dfs(cnt + 1, x + ll[cnt], y, z) + 10 r1 dfs(cnt + 1, x + ll[cnt], y, z) + 10 dfs(cnt + 1, x + ll[cnt], y, z) dfs cnt + 1 cnt 1 x + ll[cnt] x ll[cnt] ll cnt y z 10 r2 = dfs(cnt + 1, x, y + ll[cnt], z) + 10 r2 dfs(cnt + 1, x, y + ll[cnt], z) + 10 dfs(cnt + 1, x, y + ll[cnt], z) dfs cnt + 1 cnt 1 x y + ll[cnt] y ll[cnt] ll cnt z 10 r3 = dfs(cnt + 1, x, y, z + ll[cnt]) + 10 r3 dfs(cnt + 1, x, y, z + ll[cnt]) + 10 dfs(cnt + 1, x, y, z + ll[cnt]) dfs cnt + 1 cnt 1 x y z + ll[cnt] z ll[cnt] ll cnt 10 return min(r0, r1, r2, r3) min(r0, r1, r2, r3) min r0 r1 r2 r3 cnt cnt x x y y z z print(dfs(0, 0, 0, 0)) print dfs(0, 0, 0, 0) dfs 0 0 0 0 b, c = map(int, input().split()) map(int, input().split()) b c = map(int, input().split()) map(int, input().split()) c def dfs(cnt, x, y, z):
    if cnt == n:
        if x == 0 or y == 0 or z == 0:
            return float('INF')
        return abs(a - x) + abs(b - y) + abs(c - z) - 30
    r0 = dfs(cnt + 1, x, y, z)
    r1 = dfs(cnt + 1, x + ll[cnt], y, z) + 10
    r2 = dfs(cnt + 1, x, y + ll[cnt], z) + 10
    r3 = dfs(cnt + 1, x, y, z + ll[cnt]) + 10
    return min(r0, r1, r2, r3) def dfs(cnt, x, y, z):
    if cnt == n:
        if x == 0 or y == 0 or z == 0:
            return float('INF')
        return abs(a - x) + abs(b - y) + abs(c - z) - 30
    r0 = dfs(cnt + 1, x, y, z)
    r1 = dfs(cnt + 1, x + ll[cnt], y, z) + 10
    r2 = dfs(cnt + 1, x, y + ll[cnt], z) + 10
    r3 = dfs(cnt + 1, x, y, z + ll[cnt]) + 10
    return min(r0, r1, r2, r3) dfs n, a, b, c = map(int, input().split()) map(int, input().split()) n a, b, c = map(int, input().split()) map(int, input().split()) a ll = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] ll
n, a, b, c = map(int, input().split())
ll = [int(input()) for _ in range(n)]

def dfs(cnt, x, y, z):
    if cnt == n:
        if x == 0 or y == 0 or z == 0:
            return float('INF')
        return abs(a - x) + abs(b - y) + abs(c - z) - 30
    r0 = dfs(cnt + 1, x, y, z)
    r1 = dfs(cnt + 1, x + ll[cnt], y, z) + 10
    r2 = dfs(cnt + 1, x, y + ll[cnt], z) + 10
    r3 = dfs(cnt + 1, x, y, z + ll[cnt]) + 10
    return min(r0, r1, r2, r3)

print(dfs(0, 0, 0, 0))