import itertools

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

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

ans=10**9

for k in itertools.product(list(range(4)),repeat=n):

    A=[[] for i in range(4)]

    for i in range(n):

        A[k[i]]+=[l[i]]

    if A[1] and A[2] and A[3]:

        tmp=10*(n-len(A[0])-3)

        tmp+=abs(a-sum(A[1]))

        tmp+=abs(b-sum(A[2]))

        tmp+=abs(c-sum(A[3]))

        ans=min(tmp,ans)

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

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

inf=10**9

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

  if cur==N:

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

  ret0 = dfs(cur+1,a,b,c)

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

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

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

  return min(ret0,ret1,ret2,ret3)

print((dfs(0,0,0,0)))
import itertools

n, a, b, c = list(map(int, input().split()))
l = [int(eval(input())) for i in range(n)]
ans = 10**9
for k in itertools.product(list(range(4)), repeat=n):
    A = [[] for i in range(4)]
    for i in range(n):
        A[k[i]] += [l[i]]
    if A[1] and A[2] and A[3]:
        tmp = 10 * (n - len(A[0]) - 3)
        tmp += abs(a - sum(A[1]))
        tmp += abs(b - sum(A[2]))
        tmp += abs(c - sum(A[3]))
        ans = min(tmp, ans)
print(ans)

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


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


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

-import itertools +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 = [int(eval(input())) for i in range(n)] -ans = 10**9 -for k in itertools.product(list(range(4)), repeat=n): -    A = [[] for i in range(4)] -    for i in range(n): -        A[k[i]] += [l[i]] -    if A[1] and A[2] and A[3]: -        tmp = 10 * (n - len(A[0]) - 3) -        tmp += abs(a - sum(A[1])) -        tmp += abs(b - sum(A[2])) -        tmp += abs(c - sum(A[3])) -        ans = min(tmp, ans) -print(ans) + +def dfs(cur, a, b, c): +    if cur == N: +        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else inf +    ret0 = dfs(cur + 1, a, b, c) +    ret1 = dfs(cur + 1, a + l[cur], b, c) + 10 +    ret2 = dfs(cur + 1, a, b + l[cur], c) + 10 +    ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10 +    return min(ret0, ret1, ret2, ret3) + + +print((dfs(0, 0, 0, 0)))