import strutils,sequtils,math
var N,A,B,C,s=0
(N,A,B,C)=stdin.readLine.split.map parseInt
s=10^9
var
  L=mapIt(1..N,stdin.readLine.parseInt)
  D=newseq[int]N
for i in 1..4^N:
  for j in 0..<N:
    D[j]= i div 4^j mod 4
  var a,b,c,t=0
  for i,d in D:
    case d
    of 1:
      if a>0:t+=10
      a+=L[i]
    of 2:
      if b>0:t+=10
      b+=L[i]
    of 3:
      if c>0:t+=10
      c+=L[i]
    else:
      discard
  if 1 in D and 2 in D and 3 in D:
    s=min(s,abs(A-a)+abs(B-b)+abs(C-c))
echo s