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

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

INF = 10**9+7



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

	if count == N:

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

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

		else:

			return INF

	non = dfs(count+1,a,b,c)

	useA = dfs(count+1,a+l[count],b,c)+10

	useB = dfs(count+1,a,b+l[count],c)+10

	useC = dfs(count+1,a,b,c+l[count])+10

	return min(non,useA,useB,useC)



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(cnt,la,lb,lc,cost):

    if cnt == N:

        if la == 0 or lb == 0 or lc == 0:

            return 10**10

        else:

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

    else:

        a = dfs(cnt+1,la+L[cnt],lb,lc,cost+10)

        b = dfs(cnt+1,la,lb+L[cnt],lc,cost+10)

        c = dfs(cnt+1,la,lb,lc+L[cnt],cost+10)

        d = dfs(cnt+1,la,lb,lc,cost) 

        return min(a,b,c,d)



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)]
INF = 10**9 + 7


def dfs(count, a, b, c):
    if count == N:
        if min(a, b, c) > 0:
            return abs(a - A) + abs(b - B) + abs(c - C) - 30
        else:
            return INF
    non = dfs(count + 1, a, b, c)
    useA = dfs(count + 1, a + l[count], b, c) + 10
    useB = dfs(count + 1, a, b + l[count], c) + 10
    useC = dfs(count + 1, a, b, c + l[count]) + 10
    return min(non, useA, useB, useC)


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(cnt, la, lb, lc, cost):
    if cnt == N:
        if la == 0 or lb == 0 or lc == 0:
            return 10**10
        else:
            return cost + abs(A - la) + abs(B - lb) + abs(C - lc) - 30
    else:
        a = dfs(cnt + 1, la + L[cnt], lb, lc, cost + 10)
        b = dfs(cnt + 1, la, lb + L[cnt], lc, cost + 10)
        c = dfs(cnt + 1, la, lb, lc + L[cnt], cost + 10)
        d = dfs(cnt + 1, la, lb, lc, cost)
        return min(a, b, c, d)


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

-l = [int(eval(input())) for i in range(N)] -INF = 10**9 + 7 +L = [int(eval(input())) for i in range(N)] -def dfs(count, a, b, c): -    if count == N: -        if min(a, b, c) > 0: -            return abs(a - A) + abs(b - B) + abs(c - C) - 30 +def dfs(cnt, la, lb, lc, cost): +    if cnt == N: +        if la == 0 or lb == 0 or lc == 0: +            return 10**10 -            return INF -    non = dfs(count + 1, a, b, c) -    useA = dfs(count + 1, a + l[count], b, c) + 10 -    useB = dfs(count + 1, a, b + l[count], c) + 10 -    useC = dfs(count + 1, a, b, c + l[count]) + 10 -    return min(non, useA, useB, useC) +            return cost + abs(A - la) + abs(B - lb) + abs(C - lc) - 30 +    else: +        a = dfs(cnt + 1, la + L[cnt], lb, lc, cost + 10) +        b = dfs(cnt + 1, la, lb + L[cnt], lc, cost + 10) +        c = dfs(cnt + 1, la, lb, lc + L[cnt], cost + 10) +        d = dfs(cnt + 1, la, lb, lc, cost) +        return min(a, b, c, d) -print((dfs(0, 0, 0, 0))) +print((dfs(0, 0, 0, 0, 0)))