from itertools import combinations
N, A, B, C = [int(i) for i in input().split()]
l_ls = list()
for i in range(N):
    l_ls.append(int(input()))
dis_ls = [(i,[i]) for i in l_ls]
for i in range(2,7):
    dis_ls += [(sum(i),i) for i in combinations(l_ls, i)]
_sum = 0
for target in [C, B, A]:
    min = 1e9
    for dis in dis_ls:
        sa = abs(dis[0] - target) + 10 * (len(dis[1]) - 1)
        if sa < min:
            min = sa
            min_combi = dis[1]
    _sum += min
    dis_ls = [i for i in dis_ls if len(set(min_combi).intersection(set(i[1]))) == 0]
print(_sum)