import itertools

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

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

inf = float('inf')

ans = inf

for pair in itertools.product(list(range(4)),repeat=N):

    mA = 0 ; mB = 0; mC = 0; cnt = 0

    for i in range(N):

        if pair[i] == 1:

            mA += l[i]

            cnt += 1

        elif pair[i] == 2:

            mB += l[i]

            cnt += 1

        elif pair[i] == 3:

            mC += l[i]

            cnt += 1

    if mA*mB*mC == 0:continue

    cost = abs(mA-A) + abs(mB-B) + abs(mC-C) + (cnt-3)*10

    if cost < ans:

        ans = cost

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

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

inf = float('inf')



def dfs(depth=0, a=0, b=0, c=0):

    if depth == N:

        if a*b*c != 0:

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

        return inf

    res0 = dfs(depth+1,a,b,c)

    res1 = dfs(depth+1,a+l[depth],b,c) + 10

    res2 = dfs(depth+1,a,b+l[depth],c) + 10

    res3 = dfs(depth+1,a,b,c+l[depth]) + 10

    return min([res0,res1,res2,res3])



print((dfs()))
import itertools

N, A, B, C = list(map(int, input().split()))
l = [int(eval(input())) for i in range(N)]
inf = float("inf")
ans = inf
for pair in itertools.product(list(range(4)), repeat=N):
    mA = 0
    mB = 0
    mC = 0
    cnt = 0
    for i in range(N):
        if pair[i] == 1:
            mA += l[i]
            cnt += 1
        elif pair[i] == 2:
            mB += l[i]
            cnt += 1
        elif pair[i] == 3:
            mC += l[i]
            cnt += 1
    if mA * mB * mC == 0:
        continue
    cost = abs(mA - A) + abs(mB - B) + abs(mC - C) + (cnt - 3) * 10
    if cost < ans:
        ans = cost
print(ans)

N, A, B, C = list(map(int, input().split()))
l = [int(eval(input())) for i in range(N)]
inf = float("inf")


def dfs(depth=0, a=0, b=0, c=0):
    if depth == N:
        if a * b * c != 0:
            return abs(a - A) + abs(b - B) + abs(c - C) - 30
        return inf
    res0 = dfs(depth + 1, a, b, c)
    res1 = dfs(depth + 1, a + l[depth], b, c) + 10
    res2 = dfs(depth + 1, a, b + l[depth], c) + 10
    res3 = dfs(depth + 1, a, b, c + l[depth]) + 10
    return min([res0, res1, res2, res3])


print((dfs()))

-import itertools - -ans = inf -for pair in itertools.product(list(range(4)), repeat=N): -    mA = 0 -    mB = 0 -    mC = 0 -    cnt = 0 -    for i in range(N): -        if pair[i] == 1: -            mA += l[i] -            cnt += 1 -        elif pair[i] == 2: -            mB += l[i] -            cnt += 1 -        elif pair[i] == 3: -            mC += l[i] -            cnt += 1 -    if mA * mB * mC == 0: -        continue -    cost = abs(mA - A) + abs(mB - B) + abs(mC - C) + (cnt - 3) * 10 -    if cost < ans: -        ans = cost -print(ans) + + +def dfs(depth=0, a=0, b=0, c=0): +    if depth == N: +        if a * b * c != 0: +            return abs(a - A) + abs(b - B) + abs(c - C) - 30 +        return inf +    res0 = dfs(depth + 1, a, b, c) +    res1 = dfs(depth + 1, a + l[depth], b, c) + 10 +    res2 = dfs(depth + 1, a, b + l[depth], c) + 10 +    res3 = dfs(depth + 1, a, b, c + l[depth]) + 10 +    return min([res0, res1, res2, res3]) + + +print((dfs()))