N,A,B,C=map(int,input().split())
lst=[int(input()) for i in range(N)]
key=4**N
ans=float("inf")
for i in range(4**N):
 flg=[0]*N 
 for j in range(N):
  if i!=0:
   flg[j]=i%4
  i=int(i/4)
 TA=0
 TB=0
 TC=0
 TD=0
 for k in range(N):
  if flg[k]==0:
   TA+=lst[k]
  elif flg[k]==1:
   TB+=lst[k]
  elif flg[k]==2:
   TC+=lst[k]
  else:
   TD+=1
  if TA!=0 and TB!=0 and TC!=0 :
   ans=min((N-TD-3)*10+abs(A-TA)+abs(B-TB)+abs(C-TC),ans)
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 i in range(N) for i in range(N) i range(N) range N for i in range(N) int(input()) int input() input lst=[int(input()) for i in range(N)] lst [int(input()) for i in range(N)] key=4**N key 4**N 4 N ans=float("inf") ans float("inf") float "inf" for i in range(4**N):
 flg=[0]*N 
 for j in range(N):
  if i!=0:
   flg[j]=i%4
  i=int(i/4)
 TA=0
 TB=0
 TC=0
 TD=0
 for k in range(N):
  if flg[k]==0:
   TA+=lst[k]
  elif flg[k]==1:
   TB+=lst[k]
  elif flg[k]==2:
   TC+=lst[k]
  else:
   TD+=1
  if TA!=0 and TB!=0 and TC!=0 :
   ans=min((N-TD-3)*10+abs(A-TA)+abs(B-TB)+abs(C-TC),ans) i range(4**N) range 4**N 4 N flg=[0]*N flg [0]*N [0] 0 N for j in range(N):
  if i!=0:
   flg[j]=i%4
  i=int(i/4)
  j range(N) range N if i!=0:
   flg[j]=i%4
   i!=0 i 0 flg[j]=i%4 flg[j] flg j i%4 i 4 i=int(i/4) i int(i/4) int i/4 i 4 TA=0 TA 0 TB=0 TB 0 TC=0 TC 0 TD=0 TD 0 for k in range(N):
  if flg[k]==0:
   TA+=lst[k]
  elif flg[k]==1:
   TB+=lst[k]
  elif flg[k]==2:
   TC+=lst[k]
  else:
   TD+=1
  if TA!=0 and TB!=0 and TC!=0 :
   ans=min((N-TD-3)*10+abs(A-TA)+abs(B-TB)+abs(C-TC),ans) k range(N) range N if flg[k]==0:
   TA+=lst[k]
  elif flg[k]==1:
   TB+=lst[k]
  elif flg[k]==2:
   TC+=lst[k]
  else:
   TD+=1
   flg[k]==0 flg[k] flg k 0 TA+=lst[k] TA lst[k] lst k elif flg[k]==1:
   TB+=lst[k]
   flg[k]==1 flg[k] flg k 1 TB+=lst[k] TB lst[k] lst k elif flg[k]==2:
   TC+=lst[k]
   flg[k]==2 flg[k] flg k 2 TC+=lst[k] TC lst[k] lst k TD+=1 TD 1 if TA!=0 and TB!=0 and TC!=0 :
   ans=min((N-TD-3)*10+abs(A-TA)+abs(B-TB)+abs(C-TC),ans) TA!=0 and TB!=0 and TC!=0 TA!=0 and TB!=0 TA!=0 TA 0 TB!=0 TB 0 TC!=0 TC 0 ans=min((N-TD-3)*10+abs(A-TA)+abs(B-TB)+abs(C-TC),ans) ans min((N-TD-3)*10+abs(A-TA)+abs(B-TB)+abs(C-TC),ans) min (N-TD-3)*10+abs(A-TA)+abs(B-TB)+abs(C-TC) (N-TD-3)*10+abs(A-TA)+abs(B-TB) (N-TD-3)*10+abs(A-TA) (N-TD-3)*10 N-TD-3 N-TD N TD 3 10 abs(A-TA) abs A-TA A TA abs(B-TB) abs B-TB B TB abs(C-TC) abs C-TC C TC ans print(ans) print ans ans=float("inf") float("inf") ans TD+=1 1 TD TB+=lst[k] lst[k] TB TB=0 0 TB B,C=map(int,input().split()) map(int,input().split()) B TA=0 0 TA TC=0 0 TC TC+=lst[k] lst[k] TC TD=0 0 TD C=map(int,input().split()) map(int,input().split()) C A,B,C=map(int,input().split()) map(int,input().split()) A N,A,B,C=map(int,input().split()) map(int,input().split()) N key=4**N 4**N key ans=min((N-TD-3)*10+abs(A-TA)+abs(B-TB)+abs(C-TC),ans) min((N-TD-3)*10+abs(A-TA)+abs(B-TB)+abs(C-TC),ans) ans lst=[int(input()) for i in range(N)] [int(input()) for i in range(N)] lst TA+=lst[k] lst[k] TA flg=[0]*N [0]*N flg i=int(i/4) int(i/4) i
N,A,B,C=map(int,input().split())
lst=[int(input()) for i in range(N)]
key=4**N
ans=float("inf")
for i in range(4**N):
 flg=[0]*N 
 for j in range(N):
  if i!=0:
   flg[j]=i%4
  i=int(i/4)
 TA=0
 TB=0
 TC=0
 TD=0
 for k in range(N):
  if flg[k]==0:
   TA+=lst[k]
  elif flg[k]==1:
   TB+=lst[k]
  elif flg[k]==2:
   TC+=lst[k]
  else:
   TD+=1
  if TA!=0 and TB!=0 and TC!=0 :
   ans=min((N-TD-3)*10+abs(A-TA)+abs(B-TB)+abs(C-TC),ans)
print(ans)
