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