def xxx(l,n,a,b,c):
  X=10000
  for i in range(n):
    for j in range(n):
      if j==i: continue
      for k in range(n):
        if k==j or k==i: continue
        x=abs(a-l[i])+abs(b-l[j])+abs(c-l[k])
        if x<X:
          X=x
  return X
import copy
def xx(l,n,a,b,c):
  X=10000
  if n<3:
    return 10000
  else:
    for p in range(n):
      for q in range(n):
        if p!=q:
          ll=copy.deepcopy(l) 
          ll[p]+=ll[q]
          ll.pop(q)
          x=10+xxx(ll,n-1,a,b,c)
          x2=10+xx(ll,n-1,a,b,c)
          if x<X:
            X=x
          if x2<X:
            X=x2
  return X

n,a,b,c=map(int,input().split())
l=[]
for i in range(n):
  l.append(int(input()))
X=xxx(l,n,a,b,c)
if xx(l,n,a,b,c)<X:
  X=xx(l,n,a,b,c)
print(X)  