import sys
input = sys.stdin.readline


NABC=list(map(int, input().split()))
l = [int(input()) for _ in range(NABC[0])]
l.sort(reverse=True)
done = [0]*NABC[0]

ans = 1e+8
for i in range(4**NABC[0]):
    A=0
    B=0
    C=0
    A_count=-1
    B_count=-1
    C_count=-1
    i_tmp = i
    for j in range(NABC[0]):
        if l[j] <= 10: continue
        bit = i_tmp%4
        i_tmp = i_tmp//4
        if bit == 0: 
            A += l[j]
            A_count += 1
        if bit == 1:
            B += l[j]
            B_count += 1
        if bit == 2:
            C += l[j]
            C_count += 1
    if A_count==-1 or B_count==-1 or C_count==-1: continue
    tmp = abs(A-NABC[1])+abs(B-NABC[2])+abs(C-NABC[3])+max(0,A_count*10)+max(0,B_count*10)+max(0,C_count*10)
    if tmp < ans:
        ans = tmp
print(ans)


