# coding: utf-8
N,A,B,C=map(int,input().split())
L=[]
for i in range(N):
    L.append(int(input()))

def Base_10_to_n(X, base_n, len_N):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%base_n)+out
        X_dumy = int(X_dumy/base_n)
    return out.zfill(len_N)

ans=10**6

for i in range(4**N):
    bit=Base_10_to_n(i,4,N)
    group=[[] for j in range(4)]
    
    for j in range(N):
        group[int(bit[j])].append(L[j])
    
    if not(group[1]) or not(group[2]) or not(group[3]):
        continue
    
    costA = abs(A-sum(group[1])) + (len(group[1])-1)*10
    costB = abs(B-sum(group[2])) + (len(group[2])-1)*10
    costC = abs(C-sum(group[3])) + (len(group[3])-1)*10
    
    cost = costA + costB + costC
    
    ans=min(ans,cost)

print(ans) N,A,B,C=map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split A B C L=[] L [] for i in range(N):
    L.append(int(input())) i range(N) range N L.append(int(input())) L.append L append int(input()) int input() input def Base_10_to_n(X, base_n, len_N):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%base_n)+out
        X_dumy = int(X_dumy/base_n)
    return out.zfill(len_N) Base_10_to_n X_dumy = X X_dumy X out = '' out '' while X_dumy>0:
        out = str(X_dumy%base_n)+out
        X_dumy = int(X_dumy/base_n)
     X_dumy>0 X_dumy 0 out = str(X_dumy%base_n)+out out str(X_dumy%base_n)+out str(X_dumy%base_n) str X_dumy%base_n X_dumy base_n out X_dumy = int(X_dumy/base_n) X_dumy int(X_dumy/base_n) int X_dumy/base_n X_dumy base_n return out.zfill(len_N) out.zfill(len_N) out.zfill out zfill len_N X X base_n base_n len_N len_N ans=10**6 ans 10**6 10 6 for i in range(4**N):
    bit=Base_10_to_n(i,4,N)
    group=[[] for j in range(4)]
    
    for j in range(N):
        group[int(bit[j])].append(L[j])
    
    if not(group[1]) or not(group[2]) or not(group[3]):
        continue
    
    costA = abs(A-sum(group[1])) + (len(group[1])-1)*10
    costB = abs(B-sum(group[2])) + (len(group[2])-1)*10
    costC = abs(C-sum(group[3])) + (len(group[3])-1)*10
    
    cost = costA + costB + costC
    
    ans=min(ans,cost) i range(4**N) range 4**N 4 N bit=Base_10_to_n(i,4,N) bit Base_10_to_n(i,4,N) Base_10_to_n i 4 N [] for j in range(4) for j in range(4) j range(4) range 4 for j in range(4) [] group=[[] for j in range(4)] group [[] for j in range(4)] for j in range(N):
        group[int(bit[j])].append(L[j])
    
     j range(N) range N group[int(bit[j])].append(L[j]) [int(bit[j])].append [int(bit[j])] group int(bit[j]) int bit[j] bit j append L[j] L j if not(group[1]) or not(group[2]) or not(group[3]):
        continue
    
     not(group[1]) or not(group[2]) or not(group[3]) not(group[1]) or not(group[2]) not(group[1]) group[1] group 1 not(group[2]) group[2] group 2 not(group[3]) group[3] group 3 continue costA = abs(A-sum(group[1])) + (len(group[1])-1)*10 costA abs(A-sum(group[1])) + (len(group[1])-1)*10 abs(A-sum(group[1])) abs A-sum(group[1]) A sum(group[1]) sum group[1] group 1 (len(group[1])-1)*10 len(group[1])-1 len(group[1]) len group[1] group 1 1 10 costB = abs(B-sum(group[2])) + (len(group[2])-1)*10 costB abs(B-sum(group[2])) + (len(group[2])-1)*10 abs(B-sum(group[2])) abs B-sum(group[2]) B sum(group[2]) sum group[2] group 2 (len(group[2])-1)*10 len(group[2])-1 len(group[2]) len group[2] group 2 1 10 costC = abs(C-sum(group[3])) + (len(group[3])-1)*10 costC abs(C-sum(group[3])) + (len(group[3])-1)*10 abs(C-sum(group[3])) abs C-sum(group[3]) C sum(group[3]) sum group[3] group 3 (len(group[3])-1)*10 len(group[3])-1 len(group[3]) len group[3] group 3 1 10 cost = costA + costB + costC cost costA + costB + costC costA + costB costA costB costC ans=min(ans,cost) ans min(ans,cost) min ans cost print(ans) print ans bit=Base_10_to_n(i,4,N) Base_10_to_n(i,4,N) bit A,B,C=map(int,input().split()) map(int,input().split()) A costA = abs(A-sum(group[1])) + (len(group[1])-1)*10 abs(A-sum(group[1])) + (len(group[1])-1)*10 costA costB = abs(B-sum(group[2])) + (len(group[2])-1)*10 abs(B-sum(group[2])) + (len(group[2])-1)*10 costB L=[] [] L group=[[] for j in range(4)] [[] for j in range(4)] group ans=min(ans,cost) min(ans,cost) ans cost = costA + costB + costC costA + costB + costC cost costC = abs(C-sum(group[3])) + (len(group[3])-1)*10 abs(C-sum(group[3])) + (len(group[3])-1)*10 costC C=map(int,input().split()) map(int,input().split()) C def Base_10_to_n(X, base_n, len_N):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%base_n)+out
        X_dumy = int(X_dumy/base_n)
    return out.zfill(len_N) def Base_10_to_n(X, base_n, len_N):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%base_n)+out
        X_dumy = int(X_dumy/base_n)
    return out.zfill(len_N) Base_10_to_n B,C=map(int,input().split()) map(int,input().split()) B N,A,B,C=map(int,input().split()) map(int,input().split()) N ans=10**6 10**6 ans
# coding: utf-8
N,A,B,C=map(int,input().split())
L=[]
for i in range(N):
    L.append(int(input()))

def Base_10_to_n(X, base_n, len_N):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%base_n)+out
        X_dumy = int(X_dumy/base_n)
    return out.zfill(len_N)

ans=10**6

for i in range(4**N):
    bit=Base_10_to_n(i,4,N)
    group=[[] for j in range(4)]
    
    for j in range(N):
        group[int(bit[j])].append(L[j])
    
    if not(group[1]) or not(group[2]) or not(group[3]):
        continue
    
    costA = abs(A-sum(group[1])) + (len(group[1])-1)*10
    costB = abs(B-sum(group[2])) + (len(group[2])-1)*10
    costC = abs(C-sum(group[3])) + (len(group[3])-1)*10
    
    cost = costA + costB + costC
    
    ans=min(ans,cost)

print(ans)