n, a, b, c = list(map(int, input().split()))
ll = tuple([int(input()) for _ in range(n)])

def nearest(key, lst) :
    ans = float("inf")
    d = float("inf")
    for el in lst :
        if abs(el - key) < d :
            ans = el
            d = abs(el - key)
    return ans, d

def tend(lln) :
    llm = list(lln)
    al, ad = nearest(a, llm)
    llm.remove(al)
    bl, bd = nearest(b, llm)
    llm.remove(bl)
    cl, cd = nearest(c, llm)
    return ad + bd + cd

def synth(lln) :
    lol = []
    for i in range(len(lln)-1) :
        for j in range(i+1, len(lln)) :
            llm = list(lln)
            lj = llm.pop(j)
            li = llm.pop(i)
            llm.append(li+lj)
            lol.append(tuple(llm))
    return lol

def synth2(lolln) :
    lol = []
    for lln in lolln :
        lol.extend(synth(lln))
    return tuple(lol)


ans = tend(ll)
lolln = set((ll,))
for i in range(5) :
    if n >= i+4 :
        lolln = set(synth2(lolln))
        for lln in lolln :
            ans = min(ans, 10*(i+1)+tend(lln))

print(ans)