def sum_count(vec):
    return sum(vec), len(vec)-1
def main():
    N, A, B, C = list(map(int, input().split()))
    ls = []
    for _ in range(N):
        ls.append(int(input()))
    gs = [[], [], [], []]
    a = 0
    aa = [0] * N
    min_mp = 10000000000
    while a != 4^8:
        a += 1
        for i in range(N):
            aa[i] = (a//(4**i))%4
        for i, k in enumerate(aa):
            gs[k].append(ls[i])
        if any(x == [] for x in gs[1:]):
            gs = [[], [], [], []]
            continue
        else:
            abcs = []
            gousei = 0
            for abc in gs[1:]:
                s, l = sum_count(abc)
                abcs.append(s)
                abcs.sort()
                gousei += l
            mp = gousei*10 + abs(abcs[0]-A) + abs(abcs[1]-B) + abs(abcs[2]-C)
            if mp < min_mp:
                min_mp = mp
    return min_mp

            
            

main()

        
