import sys
sys.setrecursionlimit(1000000000)
INF=10**9
n,a,b,c=map(int,input().split())
l=[int(input()) for i in range(n)]
def dfs(i,x,y,z,m):
    if i==n:
        if x>0 and y>0 and z>0:
            return abs(x-a)+abs(y-b)+abs(z-c)+m
        else:
            return INF
    ans=INF
    if x==0:
        ans=min(dfs(i+1,l[i],y,z,m),ans)
    else:
        ans=min(dfs(i+1,x+l[i],y,z,m+10),ans)
    if y==0:
        ans=min(dfs(i+1,x,l[i],z,m),ans)
    else:
        ans=min(dfs(i+1,x,y+l[i],z,m+10),ans)
    if z==0:
        ans=min(dfs(i+1,x,y,l[i],m),ans)
    else:
        ans=min(dfs(i+1,x,y,z+l[i],m+10),ans)
    return min(ans,dfs(i+1,x,y,z,m))
print(dfs(0,0,0,0,0)) import sys sys sys.setrecursionlimit(1000000000) sys.setrecursionlimit sys setrecursionlimit 1000000000 INF=10**9 INF 10**9 10 9 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)] def dfs(i,x,y,z,m):
    if i==n:
        if x>0 and y>0 and z>0:
            return abs(x-a)+abs(y-b)+abs(z-c)+m
        else:
            return INF
    ans=INF
    if x==0:
        ans=min(dfs(i+1,l[i],y,z,m),ans)
    else:
        ans=min(dfs(i+1,x+l[i],y,z,m+10),ans)
    if y==0:
        ans=min(dfs(i+1,x,l[i],z,m),ans)
    else:
        ans=min(dfs(i+1,x,y+l[i],z,m+10),ans)
    if z==0:
        ans=min(dfs(i+1,x,y,l[i],m),ans)
    else:
        ans=min(dfs(i+1,x,y,z+l[i],m+10),ans)
    return min(ans,dfs(i+1,x,y,z,m)) dfs if i==n:
        if x>0 and y>0 and z>0:
            return abs(x-a)+abs(y-b)+abs(z-c)+m
        else:
            return INF
     i==n i n if x>0 and y>0 and z>0:
            return abs(x-a)+abs(y-b)+abs(z-c)+m
        else:
            return INF
     x>0 and y>0 and z>0 x>0 and y>0 x>0 x 0 y>0 y 0 z>0 z 0 return abs(x-a)+abs(y-b)+abs(z-c)+m abs(x-a)+abs(y-b)+abs(z-c)+m abs(x-a)+abs(y-b)+abs(z-c) abs(x-a)+abs(y-b) abs(x-a) abs x-a x a abs(y-b) abs y-b y b abs(z-c) abs z-c z c m return INF INF ans=INF ans INF if x==0:
        ans=min(dfs(i+1,l[i],y,z,m),ans)
    else:
        ans=min(dfs(i+1,x+l[i],y,z,m+10),ans)
     x==0 x 0 ans=min(dfs(i+1,l[i],y,z,m),ans) ans min(dfs(i+1,l[i],y,z,m),ans) min dfs(i+1,l[i],y,z,m) dfs i+1 i 1 l[i] l i y z m ans ans=min(dfs(i+1,x+l[i],y,z,m+10),ans) ans min(dfs(i+1,x+l[i],y,z,m+10),ans) min dfs(i+1,x+l[i],y,z,m+10) dfs i+1 i 1 x+l[i] x l[i] l i y z m+10 m 10 ans if y==0:
        ans=min(dfs(i+1,x,l[i],z,m),ans)
    else:
        ans=min(dfs(i+1,x,y+l[i],z,m+10),ans)
     y==0 y 0 ans=min(dfs(i+1,x,l[i],z,m),ans) ans min(dfs(i+1,x,l[i],z,m),ans) min dfs(i+1,x,l[i],z,m) dfs i+1 i 1 x l[i] l i z m ans ans=min(dfs(i+1,x,y+l[i],z,m+10),ans) ans min(dfs(i+1,x,y+l[i],z,m+10),ans) min dfs(i+1,x,y+l[i],z,m+10) dfs i+1 i 1 x y+l[i] y l[i] l i z m+10 m 10 ans if z==0:
        ans=min(dfs(i+1,x,y,l[i],m),ans)
    else:
        ans=min(dfs(i+1,x,y,z+l[i],m+10),ans)
     z==0 z 0 ans=min(dfs(i+1,x,y,l[i],m),ans) ans min(dfs(i+1,x,y,l[i],m),ans) min dfs(i+1,x,y,l[i],m) dfs i+1 i 1 x y l[i] l i m ans ans=min(dfs(i+1,x,y,z+l[i],m+10),ans) ans min(dfs(i+1,x,y,z+l[i],m+10),ans) min dfs(i+1,x,y,z+l[i],m+10) dfs i+1 i 1 x y z+l[i] z l[i] l i m+10 m 10 ans return min(ans,dfs(i+1,x,y,z,m)) min(ans,dfs(i+1,x,y,z,m)) min ans dfs(i+1,x,y,z,m) dfs i+1 i 1 x y z m i i x x y y z z m m print(dfs(0,0,0,0,0)) print dfs(0,0,0,0,0) dfs 0 0 0 0 0 l=[int(input()) for i in range(n)] [int(input()) for i in range(n)] l def dfs(i,x,y,z,m):
    if i==n:
        if x>0 and y>0 and z>0:
            return abs(x-a)+abs(y-b)+abs(z-c)+m
        else:
            return INF
    ans=INF
    if x==0:
        ans=min(dfs(i+1,l[i],y,z,m),ans)
    else:
        ans=min(dfs(i+1,x+l[i],y,z,m+10),ans)
    if y==0:
        ans=min(dfs(i+1,x,l[i],z,m),ans)
    else:
        ans=min(dfs(i+1,x,y+l[i],z,m+10),ans)
    if z==0:
        ans=min(dfs(i+1,x,y,l[i],m),ans)
    else:
        ans=min(dfs(i+1,x,y,z+l[i],m+10),ans)
    return min(ans,dfs(i+1,x,y,z,m)) def dfs(i,x,y,z,m):
    if i==n:
        if x>0 and y>0 and z>0:
            return abs(x-a)+abs(y-b)+abs(z-c)+m
        else:
            return INF
    ans=INF
    if x==0:
        ans=min(dfs(i+1,l[i],y,z,m),ans)
    else:
        ans=min(dfs(i+1,x+l[i],y,z,m+10),ans)
    if y==0:
        ans=min(dfs(i+1,x,l[i],z,m),ans)
    else:
        ans=min(dfs(i+1,x,y+l[i],z,m+10),ans)
    if z==0:
        ans=min(dfs(i+1,x,y,l[i],m),ans)
    else:
        ans=min(dfs(i+1,x,y,z+l[i],m+10),ans)
    return min(ans,dfs(i+1,x,y,z,m)) dfs n,a,b,c=map(int,input().split()) map(int,input().split()) n c=map(int,input().split()) map(int,input().split()) c b,c=map(int,input().split()) map(int,input().split()) b INF=10**9 10**9 INF a,b,c=map(int,input().split()) map(int,input().split()) a
import sys
sys.setrecursionlimit(1000000000)
INF=10**9
n,a,b,c=map(int,input().split())
l=[int(input()) for i in range(n)]
def dfs(i,x,y,z,m):
    if i==n:
        if x>0 and y>0 and z>0:
            return abs(x-a)+abs(y-b)+abs(z-c)+m
        else:
            return INF
    ans=INF
    if x==0:
        ans=min(dfs(i+1,l[i],y,z,m),ans)
    else:
        ans=min(dfs(i+1,x+l[i],y,z,m+10),ans)
    if y==0:
        ans=min(dfs(i+1,x,l[i],z,m),ans)
    else:
        ans=min(dfs(i+1,x,y+l[i],z,m+10),ans)
    if z==0:
        ans=min(dfs(i+1,x,y,l[i],m),ans)
    else:
        ans=min(dfs(i+1,x,y,z+l[i],m+10),ans)
    return min(ans,dfs(i+1,x,y,z,m))
print(dfs(0,0,0,0,0))