N,A,B,C=map(int,input().split())
l=[int(input()) for i in range(N)]
D=0
a=0
b=0
c=0
mp=10**5
#4^8=2^16=10^16*0.3010=10^5?
for i in range(4**N):
  a=0
  b=0
  c=0
  x=0
  y=0
  z=0
  for j in range(N):
    if(i&1<<2*j and i&1<<(2*j+1)):
      #A-=[l[j]
      a+=l[j]
      x+=1
    elif(i&1<<2*j and ~(i&1<<(2*j+1))):
      b+=l[j]
      y+=1
    elif(~(i&1<<2*j) and (i&1<<(2*j+1))):
      c+=l[j]
      z+=1
  if(a==0 or b==0 or c==0):
    continue

  mp=min(mp,abs(A-a)+abs(B-b)+abs(C-c)+(x+y+z-3)*10)
  if(mp==110):
    print("a={}".format(a)+"b={}".format(b)+"c={}".format(c))
print(mp) 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)] D=0 D 0 a=0 a 0 b=0 b 0 c=0 c 0 mp=10**5 mp 10**5 10 5 for i in range(4**N):
  a=0
  b=0
  c=0
  x=0
  y=0
  z=0
  for j in range(N):
    if(i&1<<2*j and i&1<<(2*j+1)):
      #A-=[l[j]
      a+=l[j]
      x+=1
    elif(i&1<<2*j and ~(i&1<<(2*j+1))):
      b+=l[j]
      y+=1
    elif(~(i&1<<2*j) and (i&1<<(2*j+1))):
      c+=l[j]
      z+=1
  if(a==0 or b==0 or c==0):
    continue

  mp=min(mp,abs(A-a)+abs(B-b)+abs(C-c)+(x+y+z-3)*10)
  if(mp==110):
    print("a={}".format(a)+"b={}".format(b)+"c={}".format(c)) i range(4**N) range 4**N 4 N a=0 a 0 b=0 b 0 c=0 c 0 x=0 x 0 y=0 y 0 z=0 z 0 for j in range(N):
    if(i&1<<2*j and i&1<<(2*j+1)):
      #A-=[l[j]
      a+=l[j]
      x+=1
    elif(i&1<<2*j and ~(i&1<<(2*j+1))):
      b+=l[j]
      y+=1
    elif(~(i&1<<2*j) and (i&1<<(2*j+1))):
      c+=l[j]
      z+=1
   j range(N) range N if(i&1<<2*j and i&1<<(2*j+1)):
      #A-=[l[j]
      a+=l[j]
      x+=1
    elif(i&1<<2*j and ~(i&1<<(2*j+1))):
      b+=l[j]
      y+=1
    elif(~(i&1<<2*j) and (i&1<<(2*j+1))):
      c+=l[j]
      z+=1
   i&1<<2*j and i&1<<(2*j+1) i&1<<2*j i 1<<2*j 1 2*j 2 j i&1<<(2*j+1) i 1<<(2*j+1) 1 2*j+1 2*j 2 j 1 a+=l[j] a l[j] l j x+=1 x 1 elif(i&1<<2*j and ~(i&1<<(2*j+1))):
      b+=l[j]
      y+=1
     i&1<<2*j and ~(i&1<<(2*j+1)) i&1<<2*j i 1<<2*j 1 2*j 2 j ~(i&1<<(2*j+1)) i&1<<(2*j+1) i 1<<(2*j+1) 1 2*j+1 2*j 2 j 1 b+=l[j] b l[j] l j y+=1 y 1 elif(~(i&1<<2*j) and (i&1<<(2*j+1))):
      c+=l[j]
      z+=1
   ~(i&1<<2*j) and (i&1<<(2*j+1)) ~(i&1<<2*j) i&1<<2*j i 1<<2*j 1 2*j 2 j i&1<<(2*j+1) i 1<<(2*j+1) 1 2*j+1 2*j 2 j 1 c+=l[j] c l[j] l j z+=1 z 1 if(a==0 or b==0 or c==0):
    continue

   a==0 or b==0 or c==0 a==0 or b==0 a==0 a 0 b==0 b 0 c==0 c 0 continue mp=min(mp,abs(A-a)+abs(B-b)+abs(C-c)+(x+y+z-3)*10) mp min(mp,abs(A-a)+abs(B-b)+abs(C-c)+(x+y+z-3)*10) min mp abs(A-a)+abs(B-b)+abs(C-c)+(x+y+z-3)*10 abs(A-a)+abs(B-b)+abs(C-c) abs(A-a)+abs(B-b) abs(A-a) abs A-a A a abs(B-b) abs B-b B b abs(C-c) abs C-c C c (x+y+z-3)*10 x+y+z-3 x+y+z x+y x y z 3 10 if(mp==110):
    print("a={}".format(a)+"b={}".format(b)+"c={}".format(c)) mp==110 mp 110 print("a={}".format(a)+"b={}".format(b)+"c={}".format(c)) print "a={}".format(a)+"b={}".format(b)+"c={}".format(c) "a={}".format(a)+"b={}".format(b) "a={}".format(a) "a={}".format "a={}" format a "b={}".format(b) "b={}".format "b={}" format b "c={}".format(c) "c={}".format "c={}" format c print(mp) print mp z+=1 1 z a+=l[j] l[j] a B,C=map(int,input().split()) map(int,input().split()) B D=0 0 D a=0 0 a x+=1 1 x l=[int(input()) for i in range(N)] [int(input()) for i in range(N)] l A,B,C=map(int,input().split()) map(int,input().split()) A c+=l[j] l[j] c N,A,B,C=map(int,input().split()) map(int,input().split()) N y=0 0 y b+=l[j] l[j] b mp=min(mp,abs(A-a)+abs(B-b)+abs(C-c)+(x+y+z-3)*10) min(mp,abs(A-a)+abs(B-b)+abs(C-c)+(x+y+z-3)*10) mp x=0 0 x a=0 0 a b=0 0 b z=0 0 z mp=10**5 10**5 mp y+=1 1 y b=0 0 b c=0 0 c C=map(int,input().split()) map(int,input().split()) C c=0 0 c
N,A,B,C=map(int,input().split())
l=[int(input()) for i in range(N)]
D=0
a=0
b=0
c=0
mp=10**5
#4^8=2^16=10^16*0.3010=10^5?
for i in range(4**N):
  a=0
  b=0
  c=0
  x=0
  y=0
  z=0
  for j in range(N):
    if(i&1<<2*j and i&1<<(2*j+1)):
      #A-=[l[j]
      a+=l[j]
      x+=1
    elif(i&1<<2*j and ~(i&1<<(2*j+1))):
      b+=l[j]
      y+=1
    elif(~(i&1<<2*j) and (i&1<<(2*j+1))):
      c+=l[j]
      z+=1
  if(a==0 or b==0 or c==0):
    continue

  mp=min(mp,abs(A-a)+abs(B-b)+abs(C-c)+(x+y+z-3)*10)
  if(mp==110):
    print("a={}".format(a)+"b={}".format(b)+"c={}".format(c))
print(mp)