n,a,b,c = map(int,input().split())
l = [int(input()) for i in range(n)]
sum_mp = 0
def check_abc(x):
    global l,sum_mp
    l.sort()
    if l.count(x)>0:
        l.remove(x)
        return
    k = -1
    for i in range(len(l)):
        if l[i]<x:
            k=i
    if k==-1:
        sum_mp += abs(x-l[0])
    elif k==0:
        sum_mp += min(abs(x-l[0]),abs(x-l[1]))
    else:
        mp_kouho = 100000
        bit_bit = []
        for i in range(1,2**(k+1)):
            bit = bit_retu(i, k+1)
            sum_length = 0
            for j in range(k+1):
                sum_length += l[j]*bit[j]
            mp_test = (bit.count(1)-1)*10 + abs(sum_length-x)
            if mp_kouho > mp_test:
                mp_kouho = mp_test
                bit_bit = bit
        if k!=len(l)-1:
            if mp_kouho > abs(x-l[k+1]):
                mp_kouho = abs(x-l[k+1])
            else:
                for i in range(k+1):
                    l[i] += 10000*bit_bit[i]
        else:
            for i in range(k+1):
                l[i] += 10000*bit_bit[i]
        sum_mp += mp_kouho
def bit_retu(x, k):
    bit = [0 for i in range(k)]
    for i in range(len(bit)):
        bit[i] = x%2
        x //=2
    return bit
abc = [a,b,c]
if l.count(a)>0:
    l.remove(a)
    abc.remove(a)
if l.count(b)>0:
    l.remove(b)
    abc.remove(b)
if l.count(c)>0:
    l.remove(c)
    abc.remove(c)
for i in range(len(abc)):
    check_abc(abc[i])
print(sum_mp)