# 8重for

# N,A,B,C = 5,100,90,80

# L = [98,40,30,21,80]

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

L = [int(eval(input())) for _ in range(N)]

ans = float('inf')

for i1 in range(4):

    for i2 in range(4):

        for i3 in range(4):

            for i4 in range(4):

                for i5 in range(4):

                    for i6 in range(4):

                        for i7 in range(4):

                            for i8 in range(4):

                                p = [i1,i2,i3,i4,i5,i6,i7,i8]

                                take = [[] for _ in range(4)] # [A,B,C,使わない]

                                for i in range(N):

                                    take[p[i]].append(L[i])

                                a,b,c = take[0],take[1],take[2]

                                if len(a)*len(b)*len(c)==0:

                                    continue 

                                cost = (len(a)+len(b)+len(c)-3)*10

                                cost += abs(sum(a)-A)+abs(sum(b)-B)+abs(sum(c)-C)

                                ans = min(ans, cost)

print(ans)
# DFS

# N,A,B,C = 5,100,90,80

# L = [98,40,30,21,80]

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

L = [int(eval(input())) for _ in range(N)]

ans = float('inf')



def dfs(cur,a,b,c)->int:

    if cur==N:

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

        else:            return float('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)))
# 8重for
# N,A,B,C = 5,100,90,80
# L = [98,40,30,21,80]
N, A, B, C = list(map(int, input().split()))
L = [int(eval(input())) for _ in range(N)]
ans = float("inf")
for i1 in range(4):
    for i2 in range(4):
        for i3 in range(4):
            for i4 in range(4):
                for i5 in range(4):
                    for i6 in range(4):
                        for i7 in range(4):
                            for i8 in range(4):
                                p = [i1, i2, i3, i4, i5, i6, i7, i8]
                                take = [[] for _ in range(4)]  # [A,B,C,使わない]
                                for i in range(N):
                                    take[p[i]].append(L[i])
                                a, b, c = take[0], take[1], take[2]
                                if len(a) * len(b) * len(c) == 0:
                                    continue
                                cost = (len(a) + len(b) + len(c) - 3) * 10
                                cost += (
                                    abs(sum(a) - A) + abs(sum(b) - B) + abs(sum(c) - C)
                                )
                                ans = min(ans, cost)
print(ans)

# DFS
# N,A,B,C = 5,100,90,80
# L = [98,40,30,21,80]
N, A, B, C = list(map(int, input().split()))
L = [int(eval(input())) for _ in range(N)]
ans = float("inf")


def dfs(cur, a, b, c) -> int:
    if cur == N:
        if min(a, b, c) > 0:
            return abs(a - A) + abs(b - B) + abs(c - C) - 30
        else:
            return float("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)))

-# 8重for +# DFS -for i1 in range(4): -    for i2 in range(4): -        for i3 in range(4): -            for i4 in range(4): -                for i5 in range(4): -                    for i6 in range(4): -                        for i7 in range(4): -                            for i8 in range(4): -                                p = [i1, i2, i3, i4, i5, i6, i7, i8] -                                take = [[] for _ in range(4)]  # [A,B,C,使わない] -                                for i in range(N): -                                    take[p[i]].append(L[i]) -                                a, b, c = take[0], take[1], take[2] -                                if len(a) * len(b) * len(c) == 0: -                                    continue -                                cost = (len(a) + len(b) + len(c) - 3) * 10 -                                cost += ( -                                    abs(sum(a) - A) + abs(sum(b) - B) + abs(sum(c) - C) -                                ) -                                ans = min(ans, cost) -print(ans) + + +def dfs(cur, a, b, c) -> int: +    if cur == N: +        if min(a, b, c) > 0: +            return abs(a - A) + abs(b - B) + abs(c - C) - 30 +        else: +            return float("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)))