def li():
    return [int(x) for x in input().split()]
INF = 10**18
import itertools as it


N, A, B, C = li()
sl = [int(input()) for x in range(N)]
todo_stack = [sl]
candidate_lists = []
seen = []
minmp = INF
target = [A, B, C]
target.sort()
minl = []
while len(todo_stack) > 0:
    l = todo_stack.pop()
    if l in seen:
        continue
    seen.append(l)
    n = len(l)
    cs = it.combinations(l, 3)
    for i in range(n):
        for j in range(n):
            for k in range(n):
                if i==j or j==k or k==i:
                    continue
                bamboos = [l[i], l[j], l[k]]
                bamboos.sort()
                diff = abs(bamboos[0] - target[0]) + abs(bamboos[1] - target[1]) + abs(bamboos[2] - target[2])
                mp = (N - n) * 10 + diff
                if mp < minmp:
                    minmp = mp
                    minl = l
    if len(l) <= 3:
        continue
    for i in range(n):
        for j in range(n):
            if i == j:
                continue
            syn = l[i] + l[j]
            others = [l[k] for k in range(n) if (k != i and k != j)]
            newl = others + [syn]
            if len(newl) >= 3:
                todo_stack.append(newl)

print(minmp)
