def func(n):

    if n == N:

        p = 0

        for c in count:

            if c == 0:

                return

            p += 10 * (c - 1)

        p += abs(length[0] - A)

        p += abs(length[1] - B)

        p += abs(length[2] - C)

        global ans

        if p < ans:

            ans = p

    else:

        count[0] += 1

        length[0] += l[n]

        func(n + 1)

        count[0] -= 1

        length[0] -= l[n]

        count[1] += 1

        length[1] += l[n]

        func(n + 1)

        count[1] -= 1

        length[1] -= l[n]

        count[2] += 1

        length[2] += l[n]

        func(n + 1)

        count[2] -= 1

        length[2] -= l[n]

        func(n + 1)





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

l = [int(eval(input())) for _ in range(N)]



ans = 3000

count = [0, 0, 0]

length = [0, 0, 0]

func(0)

print(ans)
PENALTY = 3000





def func(n, a, b, c):

    if n == N:

        return (abs(a - A) if a > 0 else PENALTY) +\

               (abs(b - B) if b > 0 else PENALTY) +\

               (abs(c - C) if c > 0 else PENALTY)

    else:

        r0 = func(n + 1, a, b, c)

        r1 = func(n + 1, a + l[n], b, c) + 10

        r2 = func(n + 1, a, b + l[n], c) + 10

        r3 = func(n + 1, a, b, c + l[n]) + 10

        return min(r0, r1, r2, r3)





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

l = [int(input()) for _ in range(N)]

ans = func(0, 0, 0, 0)

print(ans - 30)

def func(n):
    if n == N:
        p = 0
        for c in count:
            if c == 0:
                return
            p += 10 * (c - 1)
        p += abs(length[0] - A)
        p += abs(length[1] - B)
        p += abs(length[2] - C)
        global ans
        if p < ans:
            ans = p
    else:
        count[0] += 1
        length[0] += l[n]
        func(n + 1)
        count[0] -= 1
        length[0] -= l[n]
        count[1] += 1
        length[1] += l[n]
        func(n + 1)
        count[1] -= 1
        length[1] -= l[n]
        count[2] += 1
        length[2] += l[n]
        func(n + 1)
        count[2] -= 1
        length[2] -= l[n]
        func(n + 1)


N, A, B, C = list(map(int, input().split()))
l = [int(eval(input())) for _ in range(N)]
ans = 3000
count = [0, 0, 0]
length = [0, 0, 0]
func(0)
print(ans)

PENALTY = 3000


def func(n, a, b, c):
    if n == N:
        return (
            (abs(a - A) if a > 0 else PENALTY)
            + (abs(b - B) if b > 0 else PENALTY)
            + (abs(c - C) if c > 0 else PENALTY)
        )
    else:
        r0 = func(n + 1, a, b, c)
        r1 = func(n + 1, a + l[n], b, c) + 10
        r2 = func(n + 1, a, b + l[n], c) + 10
        r3 = func(n + 1, a, b, c + l[n]) + 10
        return min(r0, r1, r2, r3)


N, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(N)]
ans = func(0, 0, 0, 0)
print(ans - 30)

-def func(n): -    if n == N: -        p = 0 -        for c in count: -            if c == 0: -                return -            p += 10 * (c - 1) -        p += abs(length[0] - A) -        p += abs(length[1] - B) -        p += abs(length[2] - C) -        global ans -        if p < ans: -            ans = p -    else: -        count[0] += 1 -        length[0] += l[n] -        func(n + 1) -        count[0] -= 1 -        length[0] -= l[n] -        count[1] += 1 -        length[1] += l[n] -        func(n + 1) -        count[1] -= 1 -        length[1] -= l[n] -        count[2] += 1 -        length[2] += l[n] -        func(n + 1) -        count[2] -= 1 -        length[2] -= l[n] -        func(n + 1) +PENALTY = 3000 -N, A, B, C = list(map(int, input().split())) -l = [int(eval(input())) for _ in range(N)] -ans = 3000 -count = [0, 0, 0] -length = [0, 0, 0] -func(0) -print(ans) +def func(n, a, b, c): +    if n == N: +        return ( +            (abs(a - A) if a > 0 else PENALTY) +            + (abs(b - B) if b > 0 else PENALTY) +            + (abs(c - C) if c > 0 else PENALTY) +        ) +    else: +        r0 = func(n + 1, a, b, c) +        r1 = func(n + 1, a + l[n], b, c) + 10 +        r2 = func(n + 1, a, b + l[n], c) + 10 +        r3 = func(n + 1, a, b, c + l[n]) + 10 +        return min(r0, r1, r2, r3) + + +N, A, B, C = map(int, input().split()) +l = [int(input()) for _ in range(N)] +ans = func(0, 0, 0, 0) +print(ans - 30)