import itertools 

def diff(a,b,c):

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

    

N,A,B,C,*l=list(map(int,open(0).read().split()))

_min=10**6

for i in itertools.product([0,1,2,3],repeat=N):

    cnt=0

    abc=[0,0,0]

    for j in range(N):

        if i[j] !=3:

            abc[i[j]]+=l[j]

            cnt+=1

    if 0 in abc:

        continue

    _min=min(_min,10*cnt-30+diff(abc[0],abc[1],abc[2]))

print(_min)    

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

    if cnt == N:

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

        return _sum if min(a,b,c) > 0 else 10**9

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

    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

    return min(ret0,ret1,ret2,ret3) 

    

N,A,B,C,*l = list(map(int,open(0).read().split()))

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


def diff(a, b, c):
    return abs(A - a) + abs(B - b) + abs(C - c)


N, A, B, C, *l = list(map(int, open(0).read().split()))
_min = 10**6
for i in itertools.product([0, 1, 2, 3], repeat=N):
    cnt = 0
    abc = [0, 0, 0]
    for j in range(N):
        if i[j] != 3:
            abc[i[j]] += l[j]
            cnt += 1
    if 0 in abc:
        continue
    _min = min(_min, 10 * cnt - 30 + diff(abc[0], abc[1], abc[2]))
print(_min)

def dfs(cnt, a, b, c):
    if cnt == N:
        _sum = abs(A - a) + abs(B - b) + abs(C - c) - 30
        return _sum if min(a, b, c) > 0 else 10**9
    ret0 = dfs(cnt + 1, a, b, c)
    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
    return min(ret0, ret1, ret2, ret3)


N, A, B, C, *l = list(map(int, open(0).read().split()))
print((dfs(0, 0, 0, 0)))

-import itertools - - -def diff(a, b, c): -    return abs(A - a) + abs(B - b) + abs(C - c) +def dfs(cnt, a, b, c): +    if cnt == N: +        _sum = abs(A - a) + abs(B - b) + abs(C - c) - 30 +        return _sum if min(a, b, c) > 0 else 10**9 +    ret0 = dfs(cnt + 1, a, b, c) +    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 +    return min(ret0, ret1, ret2, ret3) -_min = 10**6 -for i in itertools.product([0, 1, 2, 3], repeat=N): -    cnt = 0 -    abc = [0, 0, 0] -    for j in range(N): -        if i[j] != 3: -            abc[i[j]] += l[j] -            cnt += 1 -    if 0 in abc: -        continue -    _min = min(_min, 10 * cnt - 30 + diff(abc[0], abc[1], abc[2])) -print(_min) +print((dfs(0, 0, 0, 0)))