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

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

INF = 10 ** 9

def dfs(cnt, a, b, c):

    if cnt == N:

        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else INF

    ret1=dfs(cnt+1,a+l[cnt],b,c)+10

    ret2=dfs(cnt+1,a,b+l[cnt],c)+10

    ret3=dfs(cnt+1,a,b,c+l[cnt])+10

    ret4=dfs(cnt+1,a,b,c)

    return min(ret1,ret2,ret3,ret4)



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

l = [0]*N

for i in range(N):

    l[i] = int(eval(input()))

def dfs(i,a,b,c):

    if i == N:

        if a==0 or b==0 or c==0:

            return 100000

        else:

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

    else:

         return min(dfs(i+1,a+l[i],b,c)+10, dfs(i+1,a,b+l[i],c)+10, dfs(i+1,a,b,c+l[i])+10, dfs(i+1,a,b,c))



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

N, A, B, C = list(map(int, input().split(" ")))
l = [int(eval(input())) for i in range(N)]
INF = 10**9


def dfs(cnt, a, b, c):
    if cnt == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
    ret1 = dfs(cnt + 1, a + l[cnt], b, c) + 10
    ret2 = dfs(cnt + 1, a, b + l[cnt], c) + 10
    ret3 = dfs(cnt + 1, a, b, c + l[cnt]) + 10
    ret4 = dfs(cnt + 1, a, b, c)
    return min(ret1, ret2, ret3, ret4)


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

N, A, B, C = list(map(int, input().split()))
l = [0] * N
for i in range(N):
    l[i] = int(eval(input()))


def dfs(i, a, b, c):
    if i == N:
        if a == 0 or b == 0 or c == 0:
            return 100000
        else:
            return abs(A - a) + abs(B - b) + abs(C - c) - 30
    else:
        return min(
            dfs(i + 1, a + l[i], b, c) + 10,
            dfs(i + 1, a, b + l[i], c) + 10,
            dfs(i + 1, a, b, c + l[i]) + 10,
            dfs(i + 1, a, b, c),
        )


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

-N, A, B, C = list(map(int, input().split(" "))) -l = [int(eval(input())) for i in range(N)] -INF = 10**9 +N, A, B, C = list(map(int, input().split())) +l = [0] * N +for i in range(N): +    l[i] = int(eval(input())) -def dfs(cnt, a, b, c): -    if cnt == N: -        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF -    ret1 = dfs(cnt + 1, a + l[cnt], b, c) + 10 -    ret2 = dfs(cnt + 1, a, b + l[cnt], c) + 10 -    ret3 = dfs(cnt + 1, a, b, c + l[cnt]) + 10 -    ret4 = dfs(cnt + 1, a, b, c) -    return min(ret1, ret2, ret3, ret4) +def dfs(i, a, b, c): +    if i == N: +        if a == 0 or b == 0 or c == 0: +            return 100000 +        else: +            return abs(A - a) + abs(B - b) + abs(C - c) - 30 +    else: +        return min( +            dfs(i + 1, a + l[i], b, c) + 10, +            dfs(i + 1, a, b + l[i], c) + 10, +            dfs(i + 1, a, b, c + l[i]) + 10, +            dfs(i + 1, a, b, c), +        )