n,a,b,c = list(map(int,input().split()))

l = []

ans = []

for i in range(n):

    l.append(int(eval(input())))



def f(x,y,z,arr,ca,cb,cc):

    global a

    global b

    global c

    global ans

    if arr:

        f(x + arr[0], y, z, arr[1:],ca+1,cb,cc)

        f(x, y + arr[0], z, arr[1:],ca,cb+1,cc)

        f(x, y, z + arr[0], arr[1:],ca,cb,cc+1)

        f(x, y, z, arr[1:],ca,cb,cc)

    else:

        if x > 0 and y > 0 and z > 0:

            ans.append(abs(a-x) + abs(b-y) + abs(c-z) + 10 * (ca + cb + cc - 3))

f(0,0,0,l,0,0,0)

print((min(ans)))
n,a,b,c = list(map(int,input().split()))

l = []

ans = []

for i in range(n):

    l.append(int(eval(input())))



def f(x,y,z,arr,cnt):

    global a

    global b

    global c

    global ans

    if arr:

        f(x + arr[0], y, z, arr[1:],cnt+1)

        f(x, y + arr[0], z, arr[1:],cnt+1)

        f(x, y, z + arr[0], arr[1:],cnt+1)

        f(x, y, z, arr[1:],cnt)

    else:

        if x > 0 and y > 0 and z > 0:

            ans.append(abs(a-x) + abs(b-y) + abs(c-z) + 10 * (cnt - 3))

f(0,0,0,l,0)

print((min(ans)))
n, a, b, c = list(map(int, input().split()))
l = []
ans = []
for i in range(n):
    l.append(int(eval(input())))


def f(x, y, z, arr, ca, cb, cc):
    global a
    global b
    global c
    global ans
    if arr:
        f(x + arr[0], y, z, arr[1:], ca + 1, cb, cc)
        f(x, y + arr[0], z, arr[1:], ca, cb + 1, cc)
        f(x, y, z + arr[0], arr[1:], ca, cb, cc + 1)
        f(x, y, z, arr[1:], ca, cb, cc)
    else:
        if x > 0 and y > 0 and z > 0:
            ans.append(abs(a - x) + abs(b - y) + abs(c - z) + 10 * (ca + cb + cc - 3))


f(0, 0, 0, l, 0, 0, 0)
print((min(ans)))

n, a, b, c = list(map(int, input().split()))
l = []
ans = []
for i in range(n):
    l.append(int(eval(input())))


def f(x, y, z, arr, cnt):
    global a
    global b
    global c
    global ans
    if arr:
        f(x + arr[0], y, z, arr[1:], cnt + 1)
        f(x, y + arr[0], z, arr[1:], cnt + 1)
        f(x, y, z + arr[0], arr[1:], cnt + 1)
        f(x, y, z, arr[1:], cnt)
    else:
        if x > 0 and y > 0 and z > 0:
            ans.append(abs(a - x) + abs(b - y) + abs(c - z) + 10 * (cnt - 3))


f(0, 0, 0, l, 0)
print((min(ans)))

-def f(x, y, z, arr, ca, cb, cc): +def f(x, y, z, arr, cnt): -        f(x + arr[0], y, z, arr[1:], ca + 1, cb, cc) -        f(x, y + arr[0], z, arr[1:], ca, cb + 1, cc) -        f(x, y, z + arr[0], arr[1:], ca, cb, cc + 1) -        f(x, y, z, arr[1:], ca, cb, cc) +        f(x + arr[0], y, z, arr[1:], cnt + 1) +        f(x, y + arr[0], z, arr[1:], cnt + 1) +        f(x, y, z + arr[0], arr[1:], cnt + 1) +        f(x, y, z, arr[1:], cnt) -            ans.append(abs(a - x) + abs(b - y) + abs(c - z) + 10 * (ca + cb + cc - 3)) +            ans.append(abs(a - x) + abs(b - y) + abs(c - z) + 10 * (cnt - 3)) -f(0, 0, 0, l, 0, 0, 0) +f(0, 0, 0, l, 0)