from itertools import combinations 
N, A, B, C = map(int, input().split())
l_list = []
for i in range(N):
    l_list.append(int(input()))
a_flg, b_flg, c_flg = True, True, True
#print(N, A, B, C)

def dff(wanted, point):
    print("dff: {}, {}, {}".format(l_list, wanted, point))
    mp1_diff = 10000
    mp1_candidate = -1
    mp2_diff = 10000
    l1, l2 = -1, -1 
    for l in l_list:
        if l == wanted: #欲しい竹だったら
            l_list.remove(l)
            return point 
        diff = abs(wanted - l)
        if mp1_diff > diff:
            mp1_diff = diff
            mp1_candidate = l

    
    for candidate in combinations(l_list, 2): 
        comb_diff = abs(wanted - sum(candidate))
        if comb_diff < mp2_diff:
            mp2_diff = comb_diff
            l1, l2 = candidate[0], candidate[1]

    if mp1_diff < mp2_diff or mp1_diff <=10:
        l_list.remove(mp1_candidate)
        l_list.append(wanted)
        return dff(wanted, point + mp1_diff)
    else:
        l_list.remove(l1)
        l_list.remove(l2)
        l_list.append(l1+l2)
        return dff(wanted, point + 10)
            
if A in l_list:
    l_list.remove(A)
    a_flg = False
if B in l_list:
    b_flg = False
    l_list.remove(C)
if C in l_list:
    c_flg = False
    l_list.remove(C)
rtn = 0
if a_flg:
    rtn += dff(A, 0)
if b_flg:
    rtn += dff(B, 0)
if c_flg:
    rtn += dff(C, 0)
print(rtn)

