import itertools



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

l = []



for i in range(N):

    l.append(int(eval(input())))

    

prod = list(itertools.product(['A','B','C','X'], repeat=N))



mps = []



for prod_e in prod:

    if prod_e.count('A') * prod_e.count('B') * prod_e.count('C') != 0:

        mp = 0

        length = {'A':0, 'B':0, 'C':0, 'X':0}

        for index, prod_e_e in enumerate(prod_e):

            length[prod_e_e] += l[index]

        mp += abs(length['A'] - A) + abs(length['B'] - B) + abs(length['C'] - C)

        mp += (prod_e.count('A')-1) * 10 + (prod_e.count('B')-1) * 10 + (prod_e.count('C')-1) * 10

        mps.append(mp)



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

l = []



for i in range(N):

    l.append(int(eval(input())))

    

def dfs(syn, n, a, b, c):

    if n == N:

        if a*b*c != 0:

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

            mp += syn * 10 - 30

            return mp

        else:

            return 10**9

    else:

        branch1 = dfs(syn+1, n+1, a + l[n], b, c)

        branch2 = dfs(syn+1, n+1, a, b + l[n], c)

        branch3 = dfs(syn+1, n+1, a, b, c + l[n])

        branch4 = dfs(syn, n+1, a, b, c)

        return min(branch1, branch2, branch3, branch4)

        

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

N, A, B, C = list(map(int, input().split()))
l = []
for i in range(N):
    l.append(int(eval(input())))
prod = list(itertools.product(["A", "B", "C", "X"], repeat=N))
mps = []
for prod_e in prod:
    if prod_e.count("A") * prod_e.count("B") * prod_e.count("C") != 0:
        mp = 0
        length = {"A": 0, "B": 0, "C": 0, "X": 0}
        for index, prod_e_e in enumerate(prod_e):
            length[prod_e_e] += l[index]
        mp += abs(length["A"] - A) + abs(length["B"] - B) + abs(length["C"] - C)
        mp += (
            (prod_e.count("A") - 1) * 10
            + (prod_e.count("B") - 1) * 10
            + (prod_e.count("C") - 1) * 10
        )
        mps.append(mp)
print((min(mps)))

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


def dfs(syn, n, a, b, c):
    if n == N:
        if a * b * c != 0:
            mp = abs(A - a) + abs(B - b) + abs(C - c)
            mp += syn * 10 - 30
            return mp
        else:
            return 10**9
    else:
        branch1 = dfs(syn + 1, n + 1, a + l[n], b, c)
        branch2 = dfs(syn + 1, n + 1, a, b + l[n], c)
        branch3 = dfs(syn + 1, n + 1, a, b, c + l[n])
        branch4 = dfs(syn, n + 1, a, b, c)
        return min(branch1, branch2, branch3, branch4)


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

-import itertools - -prod = list(itertools.product(["A", "B", "C", "X"], repeat=N)) -mps = [] -for prod_e in prod: -    if prod_e.count("A") * prod_e.count("B") * prod_e.count("C") != 0: -        mp = 0 -        length = {"A": 0, "B": 0, "C": 0, "X": 0} -        for index, prod_e_e in enumerate(prod_e): -            length[prod_e_e] += l[index] -        mp += abs(length["A"] - A) + abs(length["B"] - B) + abs(length["C"] - C) -        mp += ( -            (prod_e.count("A") - 1) * 10 -            + (prod_e.count("B") - 1) * 10 -            + (prod_e.count("C") - 1) * 10 -        ) -        mps.append(mp) -print((min(mps))) + + +def dfs(syn, n, a, b, c): +    if n == N: +        if a * b * c != 0: +            mp = abs(A - a) + abs(B - b) + abs(C - c) +            mp += syn * 10 - 30 +            return mp +        else: +            return 10**9 +    else: +        branch1 = dfs(syn + 1, n + 1, a + l[n], b, c) +        branch2 = dfs(syn + 1, n + 1, a, b + l[n], c) +        branch3 = dfs(syn + 1, n + 1, a, b, c + l[n]) +        branch4 = dfs(syn, n + 1, a, b, c) +        return min(branch1, branch2, branch3, branch4) + + +print((dfs(0, 0, 0, 0, 0)))