N, A, B, C = map(int, input().split())

take_list_global = []
for _ in range(N):
    take_list_global.append(int(input()))


abc = [A, B, C]

if A in take_list_global:
    take_list_global.remove(A)
    acb.remove(A)

if B in take_list_global:
    take_list_global.remove(B)
    abc.remove(B)

if C in take_list_global:
    take_list_global.remove(C)
    abc.remove(C)

if len(abc) == 0:
    print(0)


def combination(n: int) -> list:
    c = []
    for i in range(1<<n):
        if i == 0:
            continue
        l = []
        for j in range(n):
            if i&(1<<j) != 0:
                l.append(j)
        c.append(l)
    return c

from itertools import permutations
tar_lists = permutations(abc)

ans_list = []

for tar_list in tar_lists:
    
    ans = 0
    take_list = take_list_global.copy()
    
    for tar in tar_list:
        cost = 0
        com_lists = combination(len(take_list))
        min_abs = 1001
        min_com = []
        
        for com_list in com_lists:
            s = 0
            for c in com_list:
                s += take_list[c]
            if min_abs > abs(tar - s):
                min_abs = abs(tar - s)
                min_com = com_list

        del_take = []
        
        for c in min_com:
            del_take.append(take_list[c])

        for d in del_take:
            take_list.remove(d)

        cost += 10 * (len(min_com) - 1)
        cost += min_abs
        ans += cost

    ans_list.append(ans)

print(min(ans_list))