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