n,a,b,c=map(int,input().split())
l=[int(input()) for _ in range(n)]
def func(g):
  if len(g[0])==0 or len(g[1])==0 or len(g[2])==0:return -1
  ret=0
  ret+=10*(len(g[0])-1)
  ret+=10*(len(g[1])-1)
  ret+=10*(len(g[2])-1)
  a_=sum([l[i] for i in g[0]])
  b_=sum([l[i] for i in g[1]])
  c_=sum([l[i] for i in g[2]])
  ret+=abs(a-a_)
  ret+=abs(b-b_)
  ret+=abs(c-c_)
  return ret
m=n*2
ans=pow(10,9)
for i in range(2**m):
  g=[[]for _ in range(4)]
  for j in range(n):
    g[(i//pow(4,j))%4].append(j)
  tmp=func(g)
  if tmp>=0:
    ans=min(ans,tmp)

print(ans) 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 func(g):
  if len(g[0])==0 or len(g[1])==0 or len(g[2])==0:return -1
  ret=0
  ret+=10*(len(g[0])-1)
  ret+=10*(len(g[1])-1)
  ret+=10*(len(g[2])-1)
  a_=sum([l[i] for i in g[0]])
  b_=sum([l[i] for i in g[1]])
  c_=sum([l[i] for i in g[2]])
  ret+=abs(a-a_)
  ret+=abs(b-b_)
  ret+=abs(c-c_)
  return ret func if len(g[0])==0 or len(g[1])==0 or len(g[2])==0:return -1
   len(g[0])==0 or len(g[1])==0 or len(g[2])==0 len(g[0])==0 or len(g[1])==0 len(g[0])==0 len(g[0]) len g[0] g 0 0 len(g[1])==0 len(g[1]) len g[1] g 1 0 len(g[2])==0 len(g[2]) len g[2] g 2 0 ret=0 ret 0 ret+=10*(len(g[0])-1) ret 10*(len(g[0])-1) 10 len(g[0])-1 len(g[0]) len g[0] g 0 1 ret+=10*(len(g[1])-1) ret 10*(len(g[1])-1) 10 len(g[1])-1 len(g[1]) len g[1] g 1 1 ret+=10*(len(g[2])-1) ret 10*(len(g[2])-1) 10 len(g[2])-1 len(g[2]) len g[2] g 2 1 l[i] for i in g[0] for i in g[0] i g[0] g 0 for i in g[0] l[i] l i a_=sum([l[i] for i in g[0]]) a_ sum([l[i] for i in g[0]]) sum [l[i] for i in g[0]] l[i] for i in g[1] for i in g[1] i g[1] g 1 for i in g[1] l[i] l i b_=sum([l[i] for i in g[1]]) b_ sum([l[i] for i in g[1]]) sum [l[i] for i in g[1]] l[i] for i in g[2] for i in g[2] i g[2] g 2 for i in g[2] l[i] l i c_=sum([l[i] for i in g[2]]) c_ sum([l[i] for i in g[2]]) sum [l[i] for i in g[2]] ret+=abs(a-a_) ret abs(a-a_) abs a-a_ a a_ ret+=abs(b-b_) ret abs(b-b_) abs b-b_ b b_ ret+=abs(c-c_) ret abs(c-c_) abs c-c_ c c_ return ret ret g g m=n*2 m n*2 n 2 ans=pow(10,9) ans pow(10,9) pow 10 9 for i in range(2**m):
  g=[[]for _ in range(4)]
  for j in range(n):
    g[(i//pow(4,j))%4].append(j)
  tmp=func(g)
  if tmp>=0:
    ans=min(ans,tmp) i range(2**m) range 2**m 2 m []for _ in range(4) for _ in range(4) _ range(4) range 4 for _ in range(4) [] g=[[]for _ in range(4)] g [[]for _ in range(4)] for j in range(n):
    g[(i//pow(4,j))%4].append(j)
   j range(n) range n g[(i//pow(4,j))%4].append(j) [(i//pow(4,j))%4].append [(i//pow(4,j))%4] g (i//pow(4,j))%4 i//pow(4,j) i pow(4,j) pow 4 j 4 append j tmp=func(g) tmp func(g) func g if tmp>=0:
    ans=min(ans,tmp) tmp>=0 tmp 0 ans=min(ans,tmp) ans min(ans,tmp) min ans tmp print(ans) print ans ans=min(ans,tmp) min(ans,tmp) ans ans=pow(10,9) pow(10,9) ans def func(g):
  if len(g[0])==0 or len(g[1])==0 or len(g[2])==0:return -1
  ret=0
  ret+=10*(len(g[0])-1)
  ret+=10*(len(g[1])-1)
  ret+=10*(len(g[2])-1)
  a_=sum([l[i] for i in g[0]])
  b_=sum([l[i] for i in g[1]])
  c_=sum([l[i] for i in g[2]])
  ret+=abs(a-a_)
  ret+=abs(b-b_)
  ret+=abs(c-c_)
  return ret def func(g):
  if len(g[0])==0 or len(g[1])==0 or len(g[2])==0:return -1
  ret=0
  ret+=10*(len(g[0])-1)
  ret+=10*(len(g[1])-1)
  ret+=10*(len(g[2])-1)
  a_=sum([l[i] for i in g[0]])
  b_=sum([l[i] for i in g[1]])
  c_=sum([l[i] for i in g[2]])
  ret+=abs(a-a_)
  ret+=abs(b-b_)
  ret+=abs(c-c_)
  return ret func c=map(int,input().split()) map(int,input().split()) c a,b,c=map(int,input().split()) map(int,input().split()) a tmp=func(g) func(g) tmp g=[[]for _ in range(4)] [[]for _ in range(4)] g b,c=map(int,input().split()) map(int,input().split()) b m=n*2 n*2 m 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
n,a,b,c=map(int,input().split())
l=[int(input()) for _ in range(n)]
def func(g):
  if len(g[0])==0 or len(g[1])==0 or len(g[2])==0:return -1
  ret=0
  ret+=10*(len(g[0])-1)
  ret+=10*(len(g[1])-1)
  ret+=10*(len(g[2])-1)
  a_=sum([l[i] for i in g[0]])
  b_=sum([l[i] for i in g[1]])
  c_=sum([l[i] for i in g[2]])
  ret+=abs(a-a_)
  ret+=abs(b-b_)
  ret+=abs(c-c_)
  return ret
m=n*2
ans=pow(10,9)
for i in range(2**m):
  g=[[]for _ in range(4)]
  for j in range(n):
    g[(i//pow(4,j))%4].append(j)
  tmp=func(g)
  if tmp>=0:
    ans=min(ans,tmp)

print(ans)
