import itertools
n,A,B,C=map(int,input().split())
l=[int(input()) for i in range(n)]
ll=[]
for p in itertools.product(['A','B','C','Z'],repeat=n):
  ans=0
  a=0
  b=0
  c=0
  numa=0
  numb=0
  numc=0
  for i in range(n):
    if p[i]=='A':
      a+=l[i]
      numa+=1
    elif p[i]=='B':
      b+=l[i]
      numb+=1
    elif p[i]=='C':
      c+=l[i]
      numc+=1
  ans+=(abs(a-A)+abs(B-b)+abs(C-c)+(numa+numb+numc-3)*10)
  if all(nn!=0 for nn in [numa,numb,numc]):
    ll.append(ans)
print(min(ll)) import itertools itertools 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)] ll=[] ll [] for p in itertools.product(['A','B','C','Z'],repeat=n):
  ans=0
  a=0
  b=0
  c=0
  numa=0
  numb=0
  numc=0
  for i in range(n):
    if p[i]=='A':
      a+=l[i]
      numa+=1
    elif p[i]=='B':
      b+=l[i]
      numb+=1
    elif p[i]=='C':
      c+=l[i]
      numc+=1
  ans+=(abs(a-A)+abs(B-b)+abs(C-c)+(numa+numb+numc-3)*10)
  if all(nn!=0 for nn in [numa,numb,numc]):
    ll.append(ans) p itertools.product(['A','B','C','Z'],repeat=n) itertools.product itertools product ['A','B','C','Z'] 'A' 'B' 'C' 'Z' repeat=n repeat n ans=0 ans 0 a=0 a 0 b=0 b 0 c=0 c 0 numa=0 numa 0 numb=0 numb 0 numc=0 numc 0 for i in range(n):
    if p[i]=='A':
      a+=l[i]
      numa+=1
    elif p[i]=='B':
      b+=l[i]
      numb+=1
    elif p[i]=='C':
      c+=l[i]
      numc+=1
   i range(n) range n if p[i]=='A':
      a+=l[i]
      numa+=1
    elif p[i]=='B':
      b+=l[i]
      numb+=1
    elif p[i]=='C':
      c+=l[i]
      numc+=1
   p[i]=='A' p[i] p i 'A' a+=l[i] a l[i] l i numa+=1 numa 1 elif p[i]=='B':
      b+=l[i]
      numb+=1
     p[i]=='B' p[i] p i 'B' b+=l[i] b l[i] l i numb+=1 numb 1 elif p[i]=='C':
      c+=l[i]
      numc+=1
   p[i]=='C' p[i] p i 'C' c+=l[i] c l[i] l i numc+=1 numc 1 ans+=(abs(a-A)+abs(B-b)+abs(C-c)+(numa+numb+numc-3)*10) ans abs(a-A)+abs(B-b)+abs(C-c)+(numa+numb+numc-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 (numa+numb+numc-3)*10 numa+numb+numc-3 numa+numb+numc numa+numb numa numb numc 3 10 if all(nn!=0 for nn in [numa,numb,numc]):
    ll.append(ans) all(nn!=0 for nn in [numa,numb,numc]) all nn!=0 nn 0 ll.append(ans) ll.append ll append ans print(min(ll)) print min(ll) min ll b+=l[i] l[i] b numa=0 0 numa a=0 0 a numc=0 0 numc C=map(int,input().split()) map(int,input().split()) C numc+=1 1 numc b=0 0 b a+=l[i] l[i] a c=0 0 c ll=[] [] ll numb=0 0 numb B,C=map(int,input().split()) map(int,input().split()) B n,A,B,C=map(int,input().split()) map(int,input().split()) n l=[int(input()) for i in range(n)] [int(input()) for i in range(n)] l numb+=1 1 numb ans+=(abs(a-A)+abs(B-b)+abs(C-c)+(numa+numb+numc-3)*10) abs(a-A)+abs(B-b)+abs(C-c)+(numa+numb+numc-3)*10 ans ans=0 0 ans A,B,C=map(int,input().split()) map(int,input().split()) A numa+=1 1 numa c+=l[i] l[i] c
import itertools
n,A,B,C=map(int,input().split())
l=[int(input()) for i in range(n)]
ll=[]
for p in itertools.product(['A','B','C','Z'],repeat=n):
  ans=0
  a=0
  b=0
  c=0
  numa=0
  numb=0
  numc=0
  for i in range(n):
    if p[i]=='A':
      a+=l[i]
      numa+=1
    elif p[i]=='B':
      b+=l[i]
      numb+=1
    elif p[i]=='C':
      c+=l[i]
      numc+=1
  ans+=(abs(a-A)+abs(B-b)+abs(C-c)+(numa+numb+numc-3)*10)
  if all(nn!=0 for nn in [numa,numb,numc]):
    ll.append(ans)
print(min(ll))