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

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



INF = 1<<20

score = INF



import itertools

for ms in itertools.product(list(range(-1,3)), repeat=N):

    lens = [0]*3

    tmp_score = -30

    for i, group in enumerate(ms):

        if group>=0:

            lens[group] += l[i]

            tmp_score += 10

    if all(lens):

        score = min(score, tmp_score + abs(lens[0]-A)+abs(lens[1]-B)+abs(lens[2]-C))



print(score)

def main():

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

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

    

    INF = 1<<20

    

    def perm(n, a, b, c):

        if n == N:

            if all([a, b, c]):

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

            else:

                return INF

        return min(

            perm(n+1,a,b,c),

            perm(n+1,a+l[n],b,c)+10,

            perm(n+1,a,b+l[n],c)+10,

            perm(n+1,a,b,c+l[n])+10

            )

    

    print((perm(0,0,0,0)))



main()
N, A, B, C = list(map(int, input().split()))
l = [int(eval(input())) for _ in range(N)]
INF = 1 << 20
score = INF
import itertools

for ms in itertools.product(list(range(-1, 3)), repeat=N):
    lens = [0] * 3
    tmp_score = -30
    for i, group in enumerate(ms):
        if group >= 0:
            lens[group] += l[i]
            tmp_score += 10
    if all(lens):
        score = min(
            score, tmp_score + abs(lens[0] - A) + abs(lens[1] - B) + abs(lens[2] - C)
        )
print(score)

def main():
    N, A, B, C = list(map(int, input().split()))
    l = [int(eval(input())) for _ in range(N)]
    INF = 1 << 20

    def perm(n, a, b, c):
        if n == N:
            if all([a, b, c]):
                return abs(A - a) + abs(B - b) + abs(C - c) - 30
            else:
                return INF
        return min(
            perm(n + 1, a, b, c),
            perm(n + 1, a + l[n], b, c) + 10,
            perm(n + 1, a, b + l[n], c) + 10,
            perm(n + 1, a, b, c + l[n]) + 10,
        )

    print((perm(0, 0, 0, 0)))


main()

-N, A, B, C = list(map(int, input().split())) -l = [int(eval(input())) for _ in range(N)] -INF = 1 << 20 -score = INF -import itertools +def main(): +    N, A, B, C = list(map(int, input().split())) +    l = [int(eval(input())) for _ in range(N)] +    INF = 1 << 20 -for ms in itertools.product(list(range(-1, 3)), repeat=N): -    lens = [0] * 3 -    tmp_score = -30 -    for i, group in enumerate(ms): -        if group >= 0: -            lens[group] += l[i] -            tmp_score += 10 -    if all(lens): -        score = min( -            score, tmp_score + abs(lens[0] - A) + abs(lens[1] - B) + abs(lens[2] - C) +    def perm(n, a, b, c): +        if n == N: +            if all([a, b, c]): +                return abs(A - a) + abs(B - b) + abs(C - c) - 30 +            else: +                return INF +        return min( +            perm(n + 1, a, b, c), +            perm(n + 1, a + l[n], b, c) + 10, +            perm(n + 1, a, b + l[n], c) + 10, +            perm(n + 1, a, b, c + l[n]) + 10, -print(score) + +    print((perm(0, 0, 0, 0))) + + +main()