from itertools import product
N,A,B,C=map(int,input().split())
l=[]
for _ in range(N):
    l.append(int(input()))
ans=10**18
for i in product(range(4),repeat=N):
    mp=0
    bamboo=[0,0,0]
    for j in range(N):
        s=i[j]
        if s==3:
            continue
        else:
            if bamboo[s]!=0:
                mp+=10
            bamboo[s]+=l[j]
    if bamboo[0]==0 or bamboo[1]==0 or bamboo[2]==0:
        continue
    mp+=abs(A-bamboo[0])
    mp+=abs(B-bamboo[1])
    mp+=abs(C-bamboo[2])
    ans=min(ans,mp)
print(ans) from itertools import product 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 _ in range(N):
    l.append(int(input())) _ range(N) range N l.append(int(input())) l.append l append int(input()) int input() input ans=10**18 ans 10**18 10 18 for i in product(range(4),repeat=N):
    mp=0
    bamboo=[0,0,0]
    for j in range(N):
        s=i[j]
        if s==3:
            continue
        else:
            if bamboo[s]!=0:
                mp+=10
            bamboo[s]+=l[j]
    if bamboo[0]==0 or bamboo[1]==0 or bamboo[2]==0:
        continue
    mp+=abs(A-bamboo[0])
    mp+=abs(B-bamboo[1])
    mp+=abs(C-bamboo[2])
    ans=min(ans,mp) i product(range(4),repeat=N) product range(4) range 4 repeat=N repeat N mp=0 mp 0 bamboo=[0,0,0] bamboo [0,0,0] 0 0 0 for j in range(N):
        s=i[j]
        if s==3:
            continue
        else:
            if bamboo[s]!=0:
                mp+=10
            bamboo[s]+=l[j]
     j range(N) range N s=i[j] s i[j] i j if s==3:
            continue
        else:
            if bamboo[s]!=0:
                mp+=10
            bamboo[s]+=l[j]
     s==3 s 3 continue if bamboo[s]!=0:
                mp+=10
             bamboo[s]!=0 bamboo[s] bamboo s 0 mp+=10 mp 10 bamboo[s]+=l[j] bamboo[s] bamboo s l[j] l j if bamboo[0]==0 or bamboo[1]==0 or bamboo[2]==0:
        continue
     bamboo[0]==0 or bamboo[1]==0 or bamboo[2]==0 bamboo[0]==0 or bamboo[1]==0 bamboo[0]==0 bamboo[0] bamboo 0 0 bamboo[1]==0 bamboo[1] bamboo 1 0 bamboo[2]==0 bamboo[2] bamboo 2 0 continue mp+=abs(A-bamboo[0]) mp abs(A-bamboo[0]) abs A-bamboo[0] A bamboo[0] bamboo 0 mp+=abs(B-bamboo[1]) mp abs(B-bamboo[1]) abs B-bamboo[1] B bamboo[1] bamboo 1 mp+=abs(C-bamboo[2]) mp abs(C-bamboo[2]) abs C-bamboo[2] C bamboo[2] bamboo 2 ans=min(ans,mp) ans min(ans,mp) min ans mp print(ans) print ans l=[] [] l ans=min(ans,mp) min(ans,mp) ans bamboo=[0,0,0] [0,0,0] bamboo mp=0 0 mp mp+=abs(B-bamboo[1]) abs(B-bamboo[1]) mp B,C=map(int,input().split()) map(int,input().split()) B N,A,B,C=map(int,input().split()) map(int,input().split()) N C=map(int,input().split()) map(int,input().split()) C mp+=abs(C-bamboo[2]) abs(C-bamboo[2]) mp A,B,C=map(int,input().split()) map(int,input().split()) A ans=10**18 10**18 ans mp+=10 10 mp s=i[j] i[j] s mp+=abs(A-bamboo[0]) abs(A-bamboo[0]) mp
from itertools import product
N,A,B,C=map(int,input().split())
l=[]
for _ in range(N):
    l.append(int(input()))
ans=10**18
for i in product(range(4),repeat=N):
    mp=0
    bamboo=[0,0,0]
    for j in range(N):
        s=i[j]
        if s==3:
            continue
        else:
            if bamboo[s]!=0:
                mp+=10
            bamboo[s]+=l[j]
    if bamboo[0]==0 or bamboo[1]==0 or bamboo[2]==0:
        continue
    mp+=abs(A-bamboo[0])
    mp+=abs(B-bamboo[1])
    mp+=abs(C-bamboo[2])
    ans=min(ans,mp)
print(ans)