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

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

def dfs(cnt,A,B,C):

    if cnt == n:

        if min(A,B,C) == 0:

            return float('inf')

        else:

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

    else:

        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 = [int(eval(input())) for i in range(N)]

def dfs(i,la,lb,lc,cost):

    if i == N:

        if la*lb*lc == 0:

            return 10**20

        else:

            return abs(A-la)+abs(B-lb)+abs(C-lc)-30+cost

    ret1 = dfs(i+1,la+L[i],lb,lc,cost+10)

    ret2 = dfs(i+1,la,lb+L[i],lc,cost+10)

    ret3 = dfs(i+1,la,lb,lc+L[i],cost+10)

    ret4 = dfs(i+1,la,lb,lc,cost)

    return min(ret1,ret2,ret3,ret4)

print((dfs(0,0,0,0,0)))
n, a, b, c = list(map(int, input().split()))
l = [int(eval(input())) for i in range(n)]


def dfs(cnt, A, B, C):
    if cnt == n:
        if min(A, B, C) == 0:
            return float("inf")
        else:
            return abs(a - A) + abs(b - B) + abs(c - C) - 30
    else:
        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 = [int(eval(input())) for i in range(N)]


def dfs(i, la, lb, lc, cost):
    if i == N:
        if la * lb * lc == 0:
            return 10**20
        else:
            return abs(A - la) + abs(B - lb) + abs(C - lc) - 30 + cost
    ret1 = dfs(i + 1, la + L[i], lb, lc, cost + 10)
    ret2 = dfs(i + 1, la, lb + L[i], lc, cost + 10)
    ret3 = dfs(i + 1, la, lb, lc + L[i], cost + 10)
    ret4 = dfs(i + 1, la, lb, lc, cost)
    return min(ret1, ret2, ret3, ret4)


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

-n, a, b, c = list(map(int, input().split())) -l = [int(eval(input())) for i in range(n)] +N, A, B, C = list(map(int, input().split())) +L = [int(eval(input())) for i in range(N)] -def dfs(cnt, A, B, C): -    if cnt == n: -        if min(A, B, C) == 0: -            return float("inf") +def dfs(i, la, lb, lc, cost): +    if i == N: +        if la * lb * lc == 0: +            return 10**20 -            return abs(a - A) + abs(b - B) + abs(c - C) - 30 -    else: -        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) +            return abs(A - la) + abs(B - lb) + abs(C - lc) - 30 + cost +    ret1 = dfs(i + 1, la + L[i], lb, lc, cost + 10) +    ret2 = dfs(i + 1, la, lb + L[i], lc, cost + 10) +    ret3 = dfs(i + 1, la, lb, lc + L[i], cost + 10) +    ret4 = dfs(i + 1, la, lb, lc, cost) +    return min(ret1, ret2, ret3, ret4) -print((dfs(0, 0, 0, 0))) +print((dfs(0, 0, 0, 0, 0)))