n, *li = list(map(int, input().split()))

L = list(map(int, (int(eval(input())) for _ in range(n))))

ans = int(1e9)

def f(A, num, cnt):

    if num == n:

        if 0 in A:

            return

        global ans

        ans = min(ans, abs(A[0] - li[0]) + abs(A[1] - li[1]) + abs(A[2] - li[2]) + cnt)

        return

    for i in range(3):

        p = 0 if A[i] == 0 else 10

        B = A[::]

        B[i] += L[num]

        f(B, num + 1, cnt + p)

    f(A, num + 1, cnt)

f([0, 0, 0], 0, 0)

print(ans)

INF = float("inf")

n, A, B, C = list(map(int, input().split()))

L = tuple(map(int, (int(eval(input())) for _ in range(n))))

def f(a, b, c, num):

    if num == n:

        if min(a, b, c) > 0:

            return abs(A - a) + abs(B - b) + abs(C - c)

        else:

            return INF

    return min(

        f(a + L[num], b, c, num + 1) + (10 if a else 0),

        f(a, b + L[num], c, num + 1) + (10 if b else 0),

        f(a, b, c + L[num], num + 1) + (10 if c else 0),

        f(a, b, c, num + 1)

    )

print((f(0, 0, 0, 0)))

n, *li = list(map(int, input().split()))
L = list(map(int, (int(eval(input())) for _ in range(n))))
ans = int(1e9)


def f(A, num, cnt):
    if num == n:
        if 0 in A:
            return
        global ans
        ans = min(ans, abs(A[0] - li[0]) + abs(A[1] - li[1]) + abs(A[2] - li[2]) + cnt)
        return
    for i in range(3):
        p = 0 if A[i] == 0 else 10
        B = A[::]
        B[i] += L[num]
        f(B, num + 1, cnt + p)
    f(A, num + 1, cnt)


f([0, 0, 0], 0, 0)
print(ans)

INF = float("inf")
n, A, B, C = list(map(int, input().split()))
L = tuple(map(int, (int(eval(input())) for _ in range(n))))


def f(a, b, c, num):
    if num == n:
        if min(a, b, c) > 0:
            return abs(A - a) + abs(B - b) + abs(C - c)
        else:
            return INF
    return min(
        f(a + L[num], b, c, num + 1) + (10 if a else 0),
        f(a, b + L[num], c, num + 1) + (10 if b else 0),
        f(a, b, c + L[num], num + 1) + (10 if c else 0),
        f(a, b, c, num + 1),
    )


print((f(0, 0, 0, 0)))

-n, *li = list(map(int, input().split())) -L = list(map(int, (int(eval(input())) for _ in range(n)))) -ans = int(1e9) +INF = float("inf") +n, A, B, C = list(map(int, input().split())) +L = tuple(map(int, (int(eval(input())) for _ in range(n)))) -def f(A, num, cnt): +def f(a, b, c, num): -        if 0 in A: -            return -        global ans -        ans = min(ans, abs(A[0] - li[0]) + abs(A[1] - li[1]) + abs(A[2] - li[2]) + cnt) -        return -    for i in range(3): -        p = 0 if A[i] == 0 else 10 -        B = A[::] -        B[i] += L[num] -        f(B, num + 1, cnt + p) -    f(A, num + 1, cnt) +        if min(a, b, c) > 0: +            return abs(A - a) + abs(B - b) + abs(C - c) +        else: +            return INF +    return min( +        f(a + L[num], b, c, num + 1) + (10 if a else 0), +        f(a, b + L[num], c, num + 1) + (10 if b else 0), +        f(a, b, c + L[num], num + 1) + (10 if c else 0), +        f(a, b, c, num + 1), +    ) -f([0, 0, 0], 0, 0) -print(ans) +print((f(0, 0, 0, 0)))