n,a,b,c = map(int, input().split())
l = [int(input()) for i in range(n)]
y=[0]*n
x=[]
def dfs(n,y,now):
    if now==n:
        z=y.copy()
        x.append(z)
        return
    for i in range(4):
        y[now]=i
        dfs(n,y,now+1)
dfs(n,y,0)
mi=1000000
for i in range(len(x)):
    al,bl,cl=0,0,0
    ac,bc,cc=0,0,0
    for j in range(n):
        if x[i][j]==1:
            al+=l[j]
            ac+=1
        if x[i][j]==2:
            bl+=l[j]
            bc+=1
        if x[i][j]==3:
            cl+=l[j]
            cc+=1
    if ac!=0 and bc!=0 and cc!=0:
        ans=abs(a-al)+abs(b-bl)+abs(c-cl)+10*(ac+bc+cc-3)
        mi=min(mi,ans)
print(mi) n,a,b,c = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split a b c int(input()) for i in range(n) for i in range(n) i range(n) range n for i in range(n) int(input()) int input() input l = [int(input()) for i in range(n)] l [int(input()) for i in range(n)] y=[0]*n y [0]*n [0] 0 n x=[] x [] def dfs(n,y,now):
    if now==n:
        z=y.copy()
        x.append(z)
        return
    for i in range(4):
        y[now]=i
        dfs(n,y,now+1) dfs if now==n:
        z=y.copy()
        x.append(z)
        return
     now==n now n z=y.copy() z y.copy() y.copy y copy x.append(z) x.append x append z return for i in range(4):
        y[now]=i
        dfs(n,y,now+1) i range(4) range 4 y[now]=i y[now] y now i dfs(n,y,now+1) dfs n y now+1 now 1 n n y y now now dfs(n,y,0) dfs n y 0 mi=1000000 mi 1000000 for i in range(len(x)):
    al,bl,cl=0,0,0
    ac,bc,cc=0,0,0
    for j in range(n):
        if x[i][j]==1:
            al+=l[j]
            ac+=1
        if x[i][j]==2:
            bl+=l[j]
            bc+=1
        if x[i][j]==3:
            cl+=l[j]
            cc+=1
    if ac!=0 and bc!=0 and cc!=0:
        ans=abs(a-al)+abs(b-bl)+abs(c-cl)+10*(ac+bc+cc-3)
        mi=min(mi,ans) i range(len(x)) range len(x) len x al,bl,cl=0,0,0 al 0 bl 0 cl 0 ac,bc,cc=0,0,0 ac 0 bc 0 cc 0 for j in range(n):
        if x[i][j]==1:
            al+=l[j]
            ac+=1
        if x[i][j]==2:
            bl+=l[j]
            bc+=1
        if x[i][j]==3:
            cl+=l[j]
            cc+=1
     j range(n) range n if x[i][j]==1:
            al+=l[j]
            ac+=1
         x[i][j]==1 x[i][j] [i] x i j 1 al+=l[j] al l[j] l j ac+=1 ac 1 if x[i][j]==2:
            bl+=l[j]
            bc+=1
         x[i][j]==2 x[i][j] [i] x i j 2 bl+=l[j] bl l[j] l j bc+=1 bc 1 if x[i][j]==3:
            cl+=l[j]
            cc+=1
     x[i][j]==3 x[i][j] [i] x i j 3 cl+=l[j] cl l[j] l j cc+=1 cc 1 if ac!=0 and bc!=0 and cc!=0:
        ans=abs(a-al)+abs(b-bl)+abs(c-cl)+10*(ac+bc+cc-3)
        mi=min(mi,ans) ac!=0 and bc!=0 and cc!=0 ac!=0 and bc!=0 ac!=0 ac 0 bc!=0 bc 0 cc!=0 cc 0 ans=abs(a-al)+abs(b-bl)+abs(c-cl)+10*(ac+bc+cc-3) ans abs(a-al)+abs(b-bl)+abs(c-cl)+10*(ac+bc+cc-3) abs(a-al)+abs(b-bl)+abs(c-cl) abs(a-al)+abs(b-bl) abs(a-al) abs a-al a al abs(b-bl) abs b-bl b bl abs(c-cl) abs c-cl c cl 10*(ac+bc+cc-3) 10 ac+bc+cc-3 ac+bc+cc ac+bc ac bc cc 3 mi=min(mi,ans) mi min(mi,ans) min mi ans print(mi) print mi ans=abs(a-al)+abs(b-bl)+abs(c-cl)+10*(ac+bc+cc-3) abs(a-al)+abs(b-bl)+abs(c-cl)+10*(ac+bc+cc-3) ans x=[] [] x bc,cc=0,0,0 0 bc mi=min(mi,ans) min(mi,ans) mi ac+=1 1 ac mi=1000000 1000000 mi al,bl,cl=0,0,0 0 al a,b,c = map(int, input().split()) map(int, input().split()) a y=[0]*n [0]*n y cl=0,0,0 0 cl ac,bc,cc=0,0,0 0 ac c = map(int, input().split()) map(int, input().split()) c cc=0,0,0 0 cc bc+=1 1 bc n,a,b,c = map(int, input().split()) map(int, input().split()) n cl+=l[j] l[j] cl bl,cl=0,0,0 0 bl b,c = map(int, input().split()) map(int, input().split()) b l = [int(input()) for i in range(n)] [int(input()) for i in range(n)] l def dfs(n,y,now):
    if now==n:
        z=y.copy()
        x.append(z)
        return
    for i in range(4):
        y[now]=i
        dfs(n,y,now+1) def dfs(n,y,now):
    if now==n:
        z=y.copy()
        x.append(z)
        return
    for i in range(4):
        y[now]=i
        dfs(n,y,now+1) dfs al+=l[j] l[j] al bl+=l[j] l[j] bl cc+=1 1 cc
n,a,b,c = map(int, input().split())
l = [int(input()) for i in range(n)]
y=[0]*n
x=[]
def dfs(n,y,now):
    if now==n:
        z=y.copy()
        x.append(z)
        return
    for i in range(4):
        y[now]=i
        dfs(n,y,now+1)
dfs(n,y,0)
mi=1000000
for i in range(len(x)):
    al,bl,cl=0,0,0
    ac,bc,cc=0,0,0
    for j in range(n):
        if x[i][j]==1:
            al+=l[j]
            ac+=1
        if x[i][j]==2:
            bl+=l[j]
            bc+=1
        if x[i][j]==3:
            cl+=l[j]
            cc+=1
    if ac!=0 and bc!=0 and cc!=0:
        ans=abs(a-al)+abs(b-bl)+abs(c-cl)+10*(ac+bc+cc-3)
        mi=min(mi,ans)
print(mi)
