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):
    if i==n:
        if min(x,y,z)>0:
            return abs(x-a)+abs(y-b)+abs(z-c)-30
        else:
            return INF
    ans=dfs(i+1,x,y,z)
    ant=dfs(i+1,x+l[i],y,z)+10
    anu=dfs(i+1,x,y+l[i],z)+10
    anv=dfs(i+1,x,y,z+l[i])+10
    return min(ans,ant,anu,anv)
print(dfs(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):
    if i==n:
        if min(x,y,z)>0:
            return abs(x-a)+abs(y-b)+abs(z-c)-30
        else:
            return INF
    ans=dfs(i+1,x,y,z)
    ant=dfs(i+1,x+l[i],y,z)+10
    anu=dfs(i+1,x,y+l[i],z)+10
    anv=dfs(i+1,x,y,z+l[i])+10
    return min(ans,ant,anu,anv) dfs if i==n:
        if min(x,y,z)>0:
            return abs(x-a)+abs(y-b)+abs(z-c)-30
        else:
            return INF
     i==n i n if min(x,y,z)>0:
            return abs(x-a)+abs(y-b)+abs(z-c)-30
        else:
            return INF
     min(x,y,z)>0 min(x,y,z) min x y z 0 return abs(x-a)+abs(y-b)+abs(z-c)-30 abs(x-a)+abs(y-b)+abs(z-c)-30 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 30 return INF INF ans=dfs(i+1,x,y,z) ans dfs(i+1,x,y,z) dfs i+1 i 1 x y z ant=dfs(i+1,x+l[i],y,z)+10 ant dfs(i+1,x+l[i],y,z)+10 dfs(i+1,x+l[i],y,z) dfs i+1 i 1 x+l[i] x l[i] l i y z 10 anu=dfs(i+1,x,y+l[i],z)+10 anu dfs(i+1,x,y+l[i],z)+10 dfs(i+1,x,y+l[i],z) dfs i+1 i 1 x y+l[i] y l[i] l i z 10 anv=dfs(i+1,x,y,z+l[i])+10 anv dfs(i+1,x,y,z+l[i])+10 dfs(i+1,x,y,z+l[i]) dfs i+1 i 1 x y z+l[i] z l[i] l i 10 return min(ans,ant,anu,anv) min(ans,ant,anu,anv) min ans ant anu anv i i x x y y z z print(dfs(0,0,0,0)) print dfs(0,0,0,0) dfs 0 0 0 0 n,a,b,c=map(int,input().split()) map(int,input().split()) n c=map(int,input().split()) map(int,input().split()) c INF=10**9 10**9 INF a,b,c=map(int,input().split()) map(int,input().split()) a 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(i,x,y,z):
    if i==n:
        if min(x,y,z)>0:
            return abs(x-a)+abs(y-b)+abs(z-c)-30
        else:
            return INF
    ans=dfs(i+1,x,y,z)
    ant=dfs(i+1,x+l[i],y,z)+10
    anu=dfs(i+1,x,y+l[i],z)+10
    anv=dfs(i+1,x,y,z+l[i])+10
    return min(ans,ant,anu,anv) def dfs(i,x,y,z):
    if i==n:
        if min(x,y,z)>0:
            return abs(x-a)+abs(y-b)+abs(z-c)-30
        else:
            return INF
    ans=dfs(i+1,x,y,z)
    ant=dfs(i+1,x+l[i],y,z)+10
    anu=dfs(i+1,x,y+l[i],z)+10
    anv=dfs(i+1,x,y,z+l[i])+10
    return min(ans,ant,anu,anv) dfs
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):
    if i==n:
        if min(x,y,z)>0:
            return abs(x-a)+abs(y-b)+abs(z-c)-30
        else:
            return INF
    ans=dfs(i+1,x,y,z)
    ant=dfs(i+1,x+l[i],y,z)+10
    anu=dfs(i+1,x,y+l[i],z)+10
    anv=dfs(i+1,x,y,z+l[i])+10
    return min(ans,ant,anu,anv)
print(dfs(0,0,0,0))