n, a, b, c = map(int, input().split())
l = [int(input()) for i in range(n)]
min_ = 10**18
for i in range(4**n):
  la = []
  lb = []
  lc = []
  for j in range(n):
    i, amari = divmod(i, 4)
    if amari == 1:
      la.append(l[j])
    elif amari == 2:
      lb.append(l[j])
    elif amari == 3:
      lc.append(l[j])
    
    if len(la)>0 and len(lb)>0 and len(lc)>0:
      min_ = min(min_, abs(sum(la)-a)+10*(len(la)-1)+abs(sum(lb)-b)+10*(len(lb)-1)+abs(sum(lc)-c)+10*(len(lc)-1))
      
print(min_) 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)] min_ = 10**18 min_ 10**18 10 18 for i in range(4**n):
  la = []
  lb = []
  lc = []
  for j in range(n):
    i, amari = divmod(i, 4)
    if amari == 1:
      la.append(l[j])
    elif amari == 2:
      lb.append(l[j])
    elif amari == 3:
      lc.append(l[j])
    
    if len(la)>0 and len(lb)>0 and len(lc)>0:
      min_ = min(min_, abs(sum(la)-a)+10*(len(la)-1)+abs(sum(lb)-b)+10*(len(lb)-1)+abs(sum(lc)-c)+10*(len(lc)-1))
       i range(4**n) range 4**n 4 n la = [] la [] lb = [] lb [] lc = [] lc [] for j in range(n):
    i, amari = divmod(i, 4)
    if amari == 1:
      la.append(l[j])
    elif amari == 2:
      lb.append(l[j])
    elif amari == 3:
      lc.append(l[j])
    
    if len(la)>0 and len(lb)>0 and len(lc)>0:
      min_ = min(min_, abs(sum(la)-a)+10*(len(la)-1)+abs(sum(lb)-b)+10*(len(lb)-1)+abs(sum(lc)-c)+10*(len(lc)-1))
       j range(n) range n i, amari = divmod(i, 4) i divmod(i, 4) divmod i 4 amari if amari == 1:
      la.append(l[j])
    elif amari == 2:
      lb.append(l[j])
    elif amari == 3:
      lc.append(l[j])
    
     amari == 1 amari 1 la.append(l[j]) la.append la append l[j] l j elif amari == 2:
      lb.append(l[j])
     amari == 2 amari 2 lb.append(l[j]) lb.append lb append l[j] l j elif amari == 3:
      lc.append(l[j])
    
     amari == 3 amari 3 lc.append(l[j]) lc.append lc append l[j] l j if len(la)>0 and len(lb)>0 and len(lc)>0:
      min_ = min(min_, abs(sum(la)-a)+10*(len(la)-1)+abs(sum(lb)-b)+10*(len(lb)-1)+abs(sum(lc)-c)+10*(len(lc)-1))
       len(la)>0 and len(lb)>0 and len(lc)>0 len(la)>0 and len(lb)>0 len(la)>0 len(la) len la 0 len(lb)>0 len(lb) len lb 0 len(lc)>0 len(lc) len lc 0 min_ = min(min_, abs(sum(la)-a)+10*(len(la)-1)+abs(sum(lb)-b)+10*(len(lb)-1)+abs(sum(lc)-c)+10*(len(lc)-1)) min_ min(min_, abs(sum(la)-a)+10*(len(la)-1)+abs(sum(lb)-b)+10*(len(lb)-1)+abs(sum(lc)-c)+10*(len(lc)-1)) min min_ abs(sum(la)-a)+10*(len(la)-1)+abs(sum(lb)-b)+10*(len(lb)-1)+abs(sum(lc)-c)+10*(len(lc)-1) abs(sum(la)-a)+10*(len(la)-1)+abs(sum(lb)-b)+10*(len(lb)-1)+abs(sum(lc)-c) abs(sum(la)-a)+10*(len(la)-1)+abs(sum(lb)-b)+10*(len(lb)-1) abs(sum(la)-a)+10*(len(la)-1)+abs(sum(lb)-b) abs(sum(la)-a)+10*(len(la)-1) abs(sum(la)-a) abs sum(la)-a sum(la) sum la a 10*(len(la)-1) 10 len(la)-1 len(la) len la 1 abs(sum(lb)-b) abs sum(lb)-b sum(lb) sum lb b 10*(len(lb)-1) 10 len(lb)-1 len(lb) len lb 1 abs(sum(lc)-c) abs sum(lc)-c sum(lc) sum lc c 10*(len(lc)-1) 10 len(lc)-1 len(lc) len lc 1 print(min_) print min_ lb = [] [] lb lc = [] [] lc la = [] [] la amari = divmod(i, 4) divmod(i, 4) amari a, b, c = map(int, input().split()) map(int, input().split()) a b, c = map(int, input().split()) map(int, input().split()) b min_ = min(min_, abs(sum(la)-a)+10*(len(la)-1)+abs(sum(lb)-b)+10*(len(lb)-1)+abs(sum(lc)-c)+10*(len(lc)-1)) min(min_, abs(sum(la)-a)+10*(len(la)-1)+abs(sum(lb)-b)+10*(len(lb)-1)+abs(sum(lc)-c)+10*(len(lc)-1)) min_ i, amari = divmod(i, 4) divmod(i, 4) i l = [int(input()) for i in range(n)] [int(input()) for i in range(n)] l n, a, b, c = map(int, input().split()) map(int, input().split()) n min_ = 10**18 10**18 min_ c = map(int, input().split()) map(int, input().split()) c
n, a, b, c = map(int, input().split())
l = [int(input()) for i in range(n)]
min_ = 10**18
for i in range(4**n):
  la = []
  lb = []
  lc = []
  for j in range(n):
    i, amari = divmod(i, 4)
    if amari == 1:
      la.append(l[j])
    elif amari == 2:
      lb.append(l[j])
    elif amari == 3:
      lc.append(l[j])
    
    if len(la)>0 and len(lb)>0 and len(lc)>0:
      min_ = min(min_, abs(sum(la)-a)+10*(len(la)-1)+abs(sum(lb)-b)+10*(len(lb)-1)+abs(sum(lc)-c)+10*(len(lc)-1))
      
print(min_)