from sys import stdin
#入力
readline=stdin.readline
inf=10**9
n,a,b,c=map(int,readline().split())
l=[int(readline()) for _ in range(n)]

def dfs(now,x,y,z):
    if now==n:
        return abs(a-x)+abs(b-y)+abs(c-z)-30 if min(x,y,z)>0 else inf
    else:
        res1=dfs(now+1,x,y,z)
        res2=dfs(now+1,x+l[now],y,z)+10
        res3=dfs(now+1,x,y+l[now],z)+10
        res4=dfs(now+1,x,y,z+l[now])+10
        return min(res1,res2,res3,res4)

print(dfs(0,0,0,0)) from sys import stdin readline=stdin.readline readline stdin.readline stdin readline inf=10**9 inf 10**9 10 9 n,a,b,c=map(int,readline().split()) n map(int,readline().split()) map int readline().split() ().split () readline split a b c int(readline()) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) int(readline()) int readline() readline l=[int(readline()) for _ in range(n)] l [int(readline()) for _ in range(n)] def dfs(now,x,y,z):
    if now==n:
        return abs(a-x)+abs(b-y)+abs(c-z)-30 if min(x,y,z)>0 else inf
    else:
        res1=dfs(now+1,x,y,z)
        res2=dfs(now+1,x+l[now],y,z)+10
        res3=dfs(now+1,x,y+l[now],z)+10
        res4=dfs(now+1,x,y,z+l[now])+10
        return min(res1,res2,res3,res4) dfs if now==n:
        return abs(a-x)+abs(b-y)+abs(c-z)-30 if min(x,y,z)>0 else inf
    else:
        res1=dfs(now+1,x,y,z)
        res2=dfs(now+1,x+l[now],y,z)+10
        res3=dfs(now+1,x,y+l[now],z)+10
        res4=dfs(now+1,x,y,z+l[now])+10
        return min(res1,res2,res3,res4) now==n now n return abs(a-x)+abs(b-y)+abs(c-z)-30 if min(x,y,z)>0 else inf abs(a-x)+abs(b-y)+abs(c-z)-30 if min(x,y,z)>0 else inf min(x,y,z)>0 min(x,y,z) min x y z 0 abs(a-x)+abs(b-y)+abs(c-z)-30 abs(a-x)+abs(b-y)+abs(c-z) abs(a-x)+abs(b-y) abs(a-x) abs a-x a x abs(b-y) abs b-y b y abs(c-z) abs c-z c z 30 inf res1=dfs(now+1,x,y,z) res1 dfs(now+1,x,y,z) dfs now+1 now 1 x y z res2=dfs(now+1,x+l[now],y,z)+10 res2 dfs(now+1,x+l[now],y,z)+10 dfs(now+1,x+l[now],y,z) dfs now+1 now 1 x+l[now] x l[now] l now y z 10 res3=dfs(now+1,x,y+l[now],z)+10 res3 dfs(now+1,x,y+l[now],z)+10 dfs(now+1,x,y+l[now],z) dfs now+1 now 1 x y+l[now] y l[now] l now z 10 res4=dfs(now+1,x,y,z+l[now])+10 res4 dfs(now+1,x,y,z+l[now])+10 dfs(now+1,x,y,z+l[now]) dfs now+1 now 1 x y z+l[now] z l[now] l now 10 return min(res1,res2,res3,res4) min(res1,res2,res3,res4) min res1 res2 res3 res4 now now x x y y z z print(dfs(0,0,0,0)) print dfs(0,0,0,0) dfs 0 0 0 0 c=map(int,readline().split()) map(int,readline().split()) c def dfs(now,x,y,z):
    if now==n:
        return abs(a-x)+abs(b-y)+abs(c-z)-30 if min(x,y,z)>0 else inf
    else:
        res1=dfs(now+1,x,y,z)
        res2=dfs(now+1,x+l[now],y,z)+10
        res3=dfs(now+1,x,y+l[now],z)+10
        res4=dfs(now+1,x,y,z+l[now])+10
        return min(res1,res2,res3,res4) def dfs(now,x,y,z):
    if now==n:
        return abs(a-x)+abs(b-y)+abs(c-z)-30 if min(x,y,z)>0 else inf
    else:
        res1=dfs(now+1,x,y,z)
        res2=dfs(now+1,x+l[now],y,z)+10
        res3=dfs(now+1,x,y+l[now],z)+10
        res4=dfs(now+1,x,y,z+l[now])+10
        return min(res1,res2,res3,res4) dfs readline=stdin.readline stdin.readline readline a,b,c=map(int,readline().split()) map(int,readline().split()) a n,a,b,c=map(int,readline().split()) map(int,readline().split()) n b,c=map(int,readline().split()) map(int,readline().split()) b inf=10**9 10**9 inf l=[int(readline()) for _ in range(n)] [int(readline()) for _ in range(n)] l
from sys import stdin
#入力
readline=stdin.readline
inf=10**9
n,a,b,c=map(int,readline().split())
l=[int(readline()) for _ in range(n)]

def dfs(now,x,y,z):
    if now==n:
        return abs(a-x)+abs(b-y)+abs(c-z)-30 if min(x,y,z)>0 else inf
    else:
        res1=dfs(now+1,x,y,z)
        res2=dfs(now+1,x+l[now],y,z)+10
        res3=dfs(now+1,x,y+l[now],z)+10
        res4=dfs(now+1,x,y,z+l[now])+10
        return min(res1,res2,res3,res4)

print(dfs(0,0,0,0))