n,a,b,c=map(int,input().split())
l=[]
for i in range(n):
    l.append(int(input()))
ans=100000
for i in range(4**n):
    mp=0
    f=0
    x=[]
    y=[]
    z=[]
    w=[]
    for j in range(n):
        if i%4==0:
            x.append(l[j])
        elif i%4==1:
            y.append(l[j])
        elif i%4==2:
            z.append(l[j])
        else:
            w.append(l[j])
        i=i//4
    if sum(x)==0 or sum(y)==0 or sum(z)==0:
        f=1
    
    X=sum(x)
    Y=sum(y)
    Z=sum(z)
    mp+=(len(x)+len(y)+len(z)-3)*10
    p=[X,Y,Z]
    q=[a,b,c]
    p=sorted(p)
    q=sorted(q)
    mp+=abs(p[0]-q[0])+abs(p[1]-q[1])+abs(p[2]-q[2])
    if f!=1:     
        ans=(min(mp,ans))
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 ans=100000 ans 100000 for i in range(4**n):
    mp=0
    f=0
    x=[]
    y=[]
    z=[]
    w=[]
    for j in range(n):
        if i%4==0:
            x.append(l[j])
        elif i%4==1:
            y.append(l[j])
        elif i%4==2:
            z.append(l[j])
        else:
            w.append(l[j])
        i=i//4
    if sum(x)==0 or sum(y)==0 or sum(z)==0:
        f=1
    
    X=sum(x)
    Y=sum(y)
    Z=sum(z)
    mp+=(len(x)+len(y)+len(z)-3)*10
    p=[X,Y,Z]
    q=[a,b,c]
    p=sorted(p)
    q=sorted(q)
    mp+=abs(p[0]-q[0])+abs(p[1]-q[1])+abs(p[2]-q[2])
    if f!=1:     
        ans=(min(mp,ans)) i range(4**n) range 4**n 4 n mp=0 mp 0 f=0 f 0 x=[] x [] y=[] y [] z=[] z [] w=[] w [] for j in range(n):
        if i%4==0:
            x.append(l[j])
        elif i%4==1:
            y.append(l[j])
        elif i%4==2:
            z.append(l[j])
        else:
            w.append(l[j])
        i=i//4
     j range(n) range n if i%4==0:
            x.append(l[j])
        elif i%4==1:
            y.append(l[j])
        elif i%4==2:
            z.append(l[j])
        else:
            w.append(l[j])
         i%4==0 i%4 i 4 0 x.append(l[j]) x.append x append l[j] l j elif i%4==1:
            y.append(l[j])
         i%4==1 i%4 i 4 1 y.append(l[j]) y.append y append l[j] l j elif i%4==2:
            z.append(l[j])
         i%4==2 i%4 i 4 2 z.append(l[j]) z.append z append l[j] l j w.append(l[j]) w.append w append l[j] l j i=i//4 i i//4 i 4 if sum(x)==0 or sum(y)==0 or sum(z)==0:
        f=1
    
     sum(x)==0 or sum(y)==0 or sum(z)==0 sum(x)==0 or sum(y)==0 sum(x)==0 sum(x) sum x 0 sum(y)==0 sum(y) sum y 0 sum(z)==0 sum(z) sum z 0 f=1 f 1 X=sum(x) X sum(x) sum x Y=sum(y) Y sum(y) sum y Z=sum(z) Z sum(z) sum z mp+=(len(x)+len(y)+len(z)-3)*10 mp (len(x)+len(y)+len(z)-3)*10 len(x)+len(y)+len(z)-3 len(x)+len(y)+len(z) len(x)+len(y) len(x) len x len(y) len y len(z) len z 3 10 p=[X,Y,Z] p [X,Y,Z] X Y Z q=[a,b,c] q [a,b,c] a b c p=sorted(p) p sorted(p) sorted p q=sorted(q) q sorted(q) sorted q mp+=abs(p[0]-q[0])+abs(p[1]-q[1])+abs(p[2]-q[2]) mp abs(p[0]-q[0])+abs(p[1]-q[1])+abs(p[2]-q[2]) abs(p[0]-q[0])+abs(p[1]-q[1]) abs(p[0]-q[0]) abs p[0]-q[0] p[0] p 0 q[0] q 0 abs(p[1]-q[1]) abs p[1]-q[1] p[1] p 1 q[1] q 1 abs(p[2]-q[2]) abs p[2]-q[2] p[2] p 2 q[2] q 2 if f!=1:     
        ans=(min(mp,ans)) f!=1 f 1 ans=(min(mp,ans)) ans min(mp,ans) min mp ans print(ans) print ans mp=0 0 mp f=1 1 f p=sorted(p) sorted(p) p c=map(int,input().split()) map(int,input().split()) c x=[] [] x l=[] [] l ans=(min(mp,ans)) min(mp,ans) ans i=i//4 i//4 i Z=sum(z) sum(z) Z a,b,c=map(int,input().split()) map(int,input().split()) a q=[a,b,c] [a,b,c] q y=[] [] y Y=sum(y) sum(y) Y n,a,b,c=map(int,input().split()) map(int,input().split()) n z=[] [] z mp+=abs(p[0]-q[0])+abs(p[1]-q[1])+abs(p[2]-q[2]) abs(p[0]-q[0])+abs(p[1]-q[1])+abs(p[2]-q[2]) mp f=0 0 f ans=100000 100000 ans b,c=map(int,input().split()) map(int,input().split()) b p=[X,Y,Z] [X,Y,Z] p mp+=(len(x)+len(y)+len(z)-3)*10 (len(x)+len(y)+len(z)-3)*10 mp X=sum(x) sum(x) X q=sorted(q) sorted(q) q w=[] [] w
n,a,b,c=map(int,input().split())
l=[]
for i in range(n):
    l.append(int(input()))
ans=100000
for i in range(4**n):
    mp=0
    f=0
    x=[]
    y=[]
    z=[]
    w=[]
    for j in range(n):
        if i%4==0:
            x.append(l[j])
        elif i%4==1:
            y.append(l[j])
        elif i%4==2:
            z.append(l[j])
        else:
            w.append(l[j])
        i=i//4
    if sum(x)==0 or sum(y)==0 or sum(z)==0:
        f=1
    
    X=sum(x)
    Y=sum(y)
    Z=sum(z)
    mp+=(len(x)+len(y)+len(z)-3)*10
    p=[X,Y,Z]
    q=[a,b,c]
    p=sorted(p)
    q=sorted(q)
    mp+=abs(p[0]-q[0])+abs(p[1]-q[1])+abs(p[2]-q[2])
    if f!=1:     
        ans=(min(mp,ans))
print(ans)
    
        

    
        
        
    
