from itertools import *
N,A,B,C = map(int, input().split())
L = [int(input()) for n in range(N)]
ans = []

for i in product(range(4),repeat=N):
  a = 0
  b = 0
  c = 0
  d = 0
  for j in range(N):
    if i[j]:
      d+=1
      if i[j]==1:
        a+=L[j]
      elif i[j]==2:
        b+=L[j]
      else:
        c+=L[j]
  if a*b*c:
    ans+=[abs(A-a)+abs(B-b)+abs(C-c)+10*(d-3)]

print(min(ans)) from itertools import * 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 n in range(N) for n in range(N) n range(N) range N for n in range(N) int(input()) int input() input L = [int(input()) for n in range(N)] L [int(input()) for n in range(N)] ans = [] ans [] for i in product(range(4),repeat=N):
  a = 0
  b = 0
  c = 0
  d = 0
  for j in range(N):
    if i[j]:
      d+=1
      if i[j]==1:
        a+=L[j]
      elif i[j]==2:
        b+=L[j]
      else:
        c+=L[j]
  if a*b*c:
    ans+=[abs(A-a)+abs(B-b)+abs(C-c)+10*(d-3)] i product(range(4),repeat=N) product range(4) range 4 repeat=N repeat N a = 0 a 0 b = 0 b 0 c = 0 c 0 d = 0 d 0 for j in range(N):
    if i[j]:
      d+=1
      if i[j]==1:
        a+=L[j]
      elif i[j]==2:
        b+=L[j]
      else:
        c+=L[j]
   j range(N) range N if i[j]:
      d+=1
      if i[j]==1:
        a+=L[j]
      elif i[j]==2:
        b+=L[j]
      else:
        c+=L[j]
   i[j] i j d+=1 d 1 if i[j]==1:
        a+=L[j]
      elif i[j]==2:
        b+=L[j]
      else:
        c+=L[j]
   i[j]==1 i[j] i j 1 a+=L[j] a L[j] L j elif i[j]==2:
        b+=L[j]
       i[j]==2 i[j] i j 2 b+=L[j] b L[j] L j c+=L[j] c L[j] L j if a*b*c:
    ans+=[abs(A-a)+abs(B-b)+abs(C-c)+10*(d-3)] a*b*c a*b a b c ans+=[abs(A-a)+abs(B-b)+abs(C-c)+10*(d-3)] ans [abs(A-a)+abs(B-b)+abs(C-c)+10*(d-3)] abs(A-a)+abs(B-b)+abs(C-c)+10*(d-3) 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 10*(d-3) 10 d-3 d 3 print(min(ans)) print min(ans) min ans a = 0 0 a L = [int(input()) for n in range(N)] [int(input()) for n in range(N)] L d+=1 1 d d = 0 0 d b+=L[j] L[j] b b = 0 0 b N,A,B,C = map(int, input().split()) map(int, input().split()) N c = 0 0 c A,B,C = map(int, input().split()) map(int, input().split()) A c+=L[j] L[j] c ans = [] [] ans a+=L[j] L[j] a B,C = map(int, input().split()) map(int, input().split()) B ans+=[abs(A-a)+abs(B-b)+abs(C-c)+10*(d-3)] [abs(A-a)+abs(B-b)+abs(C-c)+10*(d-3)] ans C = map(int, input().split()) map(int, input().split()) C
from itertools import *
N,A,B,C = map(int, input().split())
L = [int(input()) for n in range(N)]
ans = []

for i in product(range(4),repeat=N):
  a = 0
  b = 0
  c = 0
  d = 0
  for j in range(N):
    if i[j]:
      d+=1
      if i[j]==1:
        a+=L[j]
      elif i[j]==2:
        b+=L[j]
      else:
        c+=L[j]
  if a*b*c:
    ans+=[abs(A-a)+abs(B-b)+abs(C-c)+10*(d-3)]

print(min(ans))