N, *ABC = map(int, input().split())
l = [int(input()) for _ in range(N)]
#print(min(min(func(l, abc)) for abc in [[A,B,C], [A,C,B], [B,A,C], [B,C,A], [C,A,B], [C,B,A]]))

def func(l, ABC, point=0):
    if len(ABC)==0:
        yield point
    else:
        x = ABC[0]
        p = min(abs(x-y) for y in l)
        if x+p in l:
            lc = l.copy()
            lc.remove(x+p)
            yield from func(lc, ABC[1:], point+p)
        if x-p in l:
            lc = l.copy()
            lc.remove(x-p)
            yield from func(lc, ABC[1:], point+p)
from itertools import chain
def func2(l, p, A, B, C):
    # for abc in [[A,B,C], [A,C,B], [B,A,C], [B,C,A], [C,A,B], [C,B,A]]:
    #     print(min(func(l, abc)))
    return min(min(func(l, abc, p)) for abc in [[A,B,C], [A,C,B], [B,A,C], [B,C,A], [C,A,B], [C,B,A]])
def grouping(l, g, h, k):
    if all(len(x)>0 for x in [g, h, k]):
        yield g, h, k
    if len(l)>0:
        a, *l = l
        yield from grouping(l, g+[a], h, k)
        yield from grouping(l, g, h+[a], k)
        yield from grouping(l, g, h, k+[a])
        yield from grouping(l, g, h, k)
def func3(l, ABC):
    for g in grouping(l, [], [], []):
        p = sum(len(gg)-1 for gg in g)*10
        yield func2(list(map(sum, g)), p, *ABC)
print(min(func3(l, ABC)))