import itertools
n,a,b,c=map(int,input().split())
l=[int(input()) for i in range(n)]
ans=100000
for p in itertools.product(['A','B','C','Z'],repeat=n):
  if list(p).count('A')>=1 and list(p).count('B')>=1 and list(p).count('C')>=1:
    for i in range(n):
      la=0
      lb=0
      lc=0
      if p[i]=='A':
        la+=p[i]
      elif p[i]=='B':
        lb+=p[i]
      elif p[i]=='C':
        lc+=p[i]
      ans=min(ans,abs(la-a)+abs(lb-b)+abs(lc-c))
print(ans)