N,A,B,C=list(map(int,input().split()))
l=[int(input()) for _ in range(N)]
target=sorted([0,A,B,C])
ans=10**10

for i in range(4**N):
    current=[0]*4
    cnt=[0]*4
    cost=0
    for j in range(N):
        b=i%4
        i//=4
        cnt[b]+=1
        current[b]+=l[j]

        if b>0 and cnt[b]>1:
            cost+=10
    
    current[0]=0
    current.sort()
    if current[1]==0:
        continue

    for j in range(1,4):
        cost+=abs(target[j]-current[j])

    ans=min(ans,cost)

print(ans) N,A,B,C=list(map(int,input().split())) N list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split A B C int(input()) for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) int(input()) int input() input l=[int(input()) for _ in range(N)] l [int(input()) for _ in range(N)] target=sorted([0,A,B,C]) target sorted([0,A,B,C]) sorted [0,A,B,C] 0 A B C ans=10**10 ans 10**10 10 10 for i in range(4**N):
    current=[0]*4
    cnt=[0]*4
    cost=0
    for j in range(N):
        b=i%4
        i//=4
        cnt[b]+=1
        current[b]+=l[j]

        if b>0 and cnt[b]>1:
            cost+=10
    
    current[0]=0
    current.sort()
    if current[1]==0:
        continue

    for j in range(1,4):
        cost+=abs(target[j]-current[j])

    ans=min(ans,cost) i range(4**N) range 4**N 4 N current=[0]*4 current [0]*4 [0] 0 4 cnt=[0]*4 cnt [0]*4 [0] 0 4 cost=0 cost 0 for j in range(N):
        b=i%4
        i//=4
        cnt[b]+=1
        current[b]+=l[j]

        if b>0 and cnt[b]>1:
            cost+=10
    
     j range(N) range N b=i%4 b i%4 i 4 i//=4 i 4 cnt[b]+=1 cnt[b] cnt b 1 current[b]+=l[j] current[b] current b l[j] l j if b>0 and cnt[b]>1:
            cost+=10
    
     b>0 and cnt[b]>1 b>0 b 0 cnt[b]>1 cnt[b] cnt b 1 cost+=10 cost 10 current[0]=0 current[0] current 0 0 current.sort() current.sort current sort if current[1]==0:
        continue

     current[1]==0 current[1] current 1 0 continue for j in range(1,4):
        cost+=abs(target[j]-current[j])

     j range(1,4) range 1 4 cost+=abs(target[j]-current[j]) cost abs(target[j]-current[j]) abs target[j]-current[j] target[j] target j current[j] current j ans=min(ans,cost) ans min(ans,cost) min ans cost print(ans) print ans i//=4 4 i N,A,B,C=list(map(int,input().split())) list(map(int,input().split())) N ans=10**10 10**10 ans A,B,C=list(map(int,input().split())) list(map(int,input().split())) A cnt=[0]*4 [0]*4 cnt target=sorted([0,A,B,C]) sorted([0,A,B,C]) target cost+=10 10 cost B,C=list(map(int,input().split())) list(map(int,input().split())) B current=[0]*4 [0]*4 current cost=0 0 cost l=[int(input()) for _ in range(N)] [int(input()) for _ in range(N)] l C=list(map(int,input().split())) list(map(int,input().split())) C ans=min(ans,cost) min(ans,cost) ans cost+=abs(target[j]-current[j]) abs(target[j]-current[j]) cost b=i%4 i%4 b
N,A,B,C=list(map(int,input().split()))
l=[int(input()) for _ in range(N)]
target=sorted([0,A,B,C])
ans=10**10

for i in range(4**N):
    current=[0]*4
    cnt=[0]*4
    cost=0
    for j in range(N):
        b=i%4
        i//=4
        cnt[b]+=1
        current[b]+=l[j]

        if b>0 and cnt[b]>1:
            cost+=10
    
    current[0]=0
    current.sort()
    if current[1]==0:
        continue

    for j in range(1,4):
        cost+=abs(target[j]-current[j])

    ans=min(ans,cost)

print(ans)